Skip to content

Commit 0db2ff0

Browse files
committed
Added more Mock files for tests
1 parent dec5ecc commit 0db2ff0

8 files changed

+67
-2227
lines changed

patches/guzzle-guzzle-update-cacert.patch

Lines changed: 0 additions & 2167 deletions
This file was deleted.

src/Message/SecureXMLAbstractRequest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Omnipay\NABTransact\Message;
44

5+
use SimpleXMLElement;
6+
57
/**
68
* NABTransact SecureXML Abstract Request.
79
*/
@@ -71,27 +73,31 @@ public function getMessageId()
7173
return $this->getParameter('messageId');
7274
}
7375

76+
/**
77+
* @param $data
78+
* @return mixed
79+
*/
7480
public function sendData($data)
7581
{
7682
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], $data->asXML());
7783

78-
$xml = new \SimpleXMLElement($httpResponse->getBody()->getContents());
84+
$xml = new SimpleXMLElement($httpResponse->getBody()->getContents());
7985

8086
return $this->response = new SecureXMLResponse($this, $xml);
8187
}
8288

8389
/**
8490
* XML Template of a NABTransactMessage.
8591
*
86-
* @return \SimpleXMLElement NABTransactMessage template.
92+
* @return SimpleXMLElement NABTransactMessage template.
8793
*/
8894
protected function getBaseXML()
8995
{
9096
foreach ($this->requiredFields as $field) {
9197
$this->validate($field);
9298
}
9399

94-
$xml = new \SimpleXMLElement('<NABTransactMessage/>');
100+
$xml = new SimpleXMLElement('<NABTransactMessage/>');
95101

96102
$messageInfo = $xml->addChild('MessageInfo');
97103
$messageInfo->messageID = $this->getMessageId();
@@ -111,7 +117,7 @@ protected function getBaseXML()
111117
/**
112118
* XML template of a NABTransactMessage Payment.
113119
*
114-
* @return \SimpleXMLElement NABTransactMessage with transaction details.
120+
* @return SimpleXMLElement NABTransactMessage with transaction details.
115121
*/
116122
protected function getBasePaymentXML()
117123
{
@@ -135,7 +141,7 @@ protected function getBasePaymentXML()
135141
/**
136142
* NABTransactMessage with transaction and card details.
137143
*
138-
* @return \SimpleXMLElement
144+
* @return SimpleXMLElement
139145
*/
140146
protected function getBasePaymentXMLWithCard()
141147
{

tests/Message/SecureXMLAuthorizeRequestTest.php

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,24 @@ public function setUp()
1111
$this->request = new SecureXMLAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
1212

1313
$this->request->initialize([
14-
'merchantId' => 'XYZ0010',
14+
'merchantId' => 'XYZ0010',
1515
'transactionPassword' => 'abcd1234',
16-
'testMode' => true,
17-
'amount' => '12.00',
18-
'transactionId' => '1234',
19-
'card' => [
20-
'number' => '4444333322221111',
21-
'expiryMonth' => '10',
22-
'expiryYear' => '2030',
23-
'cvv' => '123',
16+
'testMode' => true,
17+
'amount' => '12.00',
18+
'transactionId' => '1234',
19+
'card' => [
20+
'number' => '4444333322221111',
21+
'expiryMonth' => '10',
22+
'expiryYear' => '2030',
23+
'cvv' => '123',
2424
'cardHolderName' => 'Sujip Thapa',
2525
],
2626
]);
2727
}
2828

2929
public function testSendSuccess()
3030
{
31-
$data = [];
32-
33-
$data['RequestType'] = 'Payment';
34-
$data['statusDescription'] = 'Normal';
35-
$data['statusCode'] = '000';
36-
$data['apiVersion'] = 'xml-4.2';
37-
$data['txnType'] = '10';
38-
$data['txnSource'] = '23';
39-
$data['amount'] = '12.00';
40-
$data['currency'] = 'AUD';
41-
$data['approved'] = 'Yes';
42-
$data['responseCode'] = '00';
43-
$data['responseText'] = 'Approved';
44-
$data['txnID'] = '1234';
45-
$data['cardDescription'] = 'Visa';
46-
$data['expiryDate'] = '10/30';
47-
$data['cardType'] = '6';
48-
49-
$response = new SecureXMLResponse($this->getMockRequest(), $data);
31+
$this->setMockHttpResponse('SecureXMLAuthorizeRequestSuccess.txt');
5032

5133
$response = $this->request->send();
5234

@@ -63,7 +45,7 @@ public function testSendSuccess()
6345
$this->assertNotNull($response->getTransactionId());
6446
$this->assertSame('Approved', $response->getMessage());
6547
$this->assertSame('00', $response->getCode());
66-
$this->assertSame('10', (string) $data->Payment->TxnList->Txn->txnType);
48+
$this->assertSame('0', (string) $data->Payment->TxnList->Txn->txnType);
6749
}
6850

6951
public function testSendFailure()

tests/Message/SecureXMLEchoTestRequestTest.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ public function setUp()
1919

2020
public function testSuccess()
2121
{
22-
$data = [];
23-
24-
$data['RequestType'] = 'Echo';
25-
$data['statusDescription'] = 'Normal';
26-
$data['statusCode'] = '000';
27-
$data['apiVersion'] = 'xml-4.2';
28-
29-
$response = new SecureXMLResponse($this->getMockRequest(), $data);
22+
$this->setMockHttpResponse('SecureXMLEchoTestRequestSuccess.txt');
3023

3124
$response = $this->request->send();
3225
$data = $response->getData();

tests/Message/SecureXMLPurchaseRequestTest.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,7 @@ public function setUp()
2828

2929
public function testSendSuccess()
3030
{
31-
$data = [];
32-
33-
$data['RequestType'] = 'Payment';
34-
$data['statusDescription'] = 'Normal';
35-
$data['statusCode'] = '000';
36-
$data['apiVersion'] = 'xml-4.2';
37-
$data['txnType'] = '10';
38-
$data['txnSource'] = '23';
39-
$data['amount'] = '12.00';
40-
$data['currency'] = 'AUD';
41-
$data['approved'] = 'Yes';
42-
$data['responseCode'] = '00';
43-
$data['responseText'] = 'Approved';
44-
$data['cardDescription'] = 'Visa';
45-
$data['expiryDate'] = '10/30';
46-
$data['cardType'] = '6';
47-
48-
$response = new SecureXMLResponse($this->getMockRequest(), $data);
31+
$this->setMockHttpResponse('SecureXMLPurchaseRequestSendSuccess.txt');
4932

5033
$response = $this->request->send();
5134
$data = $response->getData();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
HTTP/1.1 100 Continue
2+
Server: Microsoft-IIS/5.0
3+
Date: Sat, 26 May 2018 07:25:31 GMT
4+
HTTP/1.1 200 OK
5+
Server: Microsoft-IIS/5.0
6+
Date: Sat, 26 May 2018 07:25:31 GMT
7+
Content-Type: text/xml;charset=ISO-8859-1
8+
Content-Length: 929
9+
10+
<?xml version="1.0" encoding="UTF-8" standalone="no"?><NABTransactMessage><MessageInfo><messageID>a246d3d2ff1a75298ebe54f21fe887</messageID><messageTimestamp>20182605172441033000+600</messageTimestamp><apiVersion>xml-4.2</apiVersion></MessageInfo><RequestType>Payment</RequestType><MerchantInfo><merchantID>XYZ0010</merchantID></MerchantInfo><Status><statusCode>000</statusCode><statusDescription>Normal</statusDescription></Status><Payment><TxnList count="1"><Txn ID="1"><txnType>0</txnType><txnSource>23</txnSource><amount>1200</amount><currency>AUD</currency><purchaseOrderNo>ORDER-ZYX8789</purchaseOrderNo><approved>Yes</approved><responseCode>00</responseCode><responseText>Approved</responseText><settlementDate>20180526</settlementDate><txnID>800055</txnID><authID>711736</authID><CreditCardInfo><pan>444433...111</pan><expiryDate>12/18</expiryDate><cardType>6</cardType><cardDescription>Visa</cardDescription></CreditCardInfo></Txn></TxnList></Payment></NABTransactMessage>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
HTTP/1.1 100 Continue
2+
Server: Microsoft-IIS/5.0
3+
Date: Sat, 26 May 2018 07:25:31 GMT
4+
HTTP/1.1 200 OK
5+
Server: Microsoft-IIS/5.0
6+
Date: Sat, 26 May 2018 07:25:31 GMT
7+
Content-Type: text/xml;charset=ISO-8859-1
8+
Content-Length: 929
9+
10+
<?xml version="1.0" encoding="UTF-8"?>
11+
<NABTransactMessage>
12+
<MessageInfo>
13+
<messageID>a246d3d2ff1a75298ebe54f21fe887</messageID>
14+
<messageTimestamp>20182605172441033000+600</messageTimestamp>
15+
<apiVersion>xml-4.2</apiVersion>
16+
</MessageInfo>
17+
<RequestType>Echo</RequestType>
18+
<Status>
19+
<statusCode>000</statusCode>
20+
<statusDescription>Normal</statusDescription>
21+
</Status>
22+
</NABTransactMessage>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
HTTP/1.1 100 Continue
2+
Server: Microsoft-IIS/5.0
3+
Date: Sat, 26 May 2018 07:25:31 GMT
4+
HTTP/1.1 200 OK
5+
Server: Microsoft-IIS/5.0
6+
Date: Sat, 26 May 2018 07:25:31 GMT
7+
Content-Type: text/xml;charset=ISO-8859-1
8+
Content-Length: 929
9+
10+
<?xml version="1.0" encoding="UTF-8"?>
11+
<NABTransactMessage><MessageInfo><messageID>a246d3d2ff1a75298ebe54f21fe887</messageID><messageTimestamp>20182605172441033000+600</messageTimestamp><apiVersion>xml-4.2</apiVersion></MessageInfo><RequestType>Payment</RequestType><MerchantInfo><merchantID>XYZ0010</merchantID></MerchantInfo><Status><statusCode>00</statusCode><statusDescription>Normal</statusDescription></Status><Payment><TxnList count="1"><Txn ID="1"><txnType>0</txnType><txnSource>23</txnSource><amount>200</amount><currency>AUD</currency><purchaseOrderNo>1234</purchaseOrderNo><approved>Yes</approved><responseCode>00</responseCode><responseText>Approved</responseText><settlementDate>20180526</settlementDate><txnID>009729</txnID><CreditCardInfo><pan>424242...242</pan><expiryDate>07/06</expiryDate><cardType>6</cardType><cardDescription>Visa</cardDescription></CreditCardInfo></Txn></TxnList></Payment></NABTransactMessage>

0 commit comments

Comments
 (0)