Skip to content

Commit c799cd2

Browse files
author
David Stockton
committed
Fix for unit test, notices
1 parent 788222a commit c799cd2

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/Message/AIMResponse.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ class AIMResponse extends AbstractResponse
1414
public function __construct(RequestInterface $request, $data)
1515
{
1616
$this->request = $request;
17-
$temp = explode('|,|', substr($data, 1, -1));
17+
$rawFields = substr($data, 1, - 1);
18+
if ($rawFields !== false) {
19+
$temp = explode('|,|', $rawFields);
20+
} else {
21+
$temp = [];
22+
}
1823

1924
$response_fields = array(
2025
'Response Code',
@@ -67,7 +72,10 @@ public function __construct(RequestInterface $request, $data)
6772
$response = array();
6873

6974
foreach ($response_fields as $field) {
70-
$response[$field] = array_shift($temp);
75+
$responseField = array_shift($temp);
76+
if (!is_null($responseField)) {
77+
$response[$field] = $responseField;
78+
}
7179
}
7280

7381
$response_codes = array(
@@ -93,8 +101,17 @@ public function __construct(RequestInterface $request, $data)
93101
'Z' => 'Five digit ZIP matches, Address (Street) does not'
94102
);
95103

96-
$response['Response Code'] = $response_codes[$response['Response Code']];
97-
$response['AVS Response'] = $avs_response_codes[$response['AVS Response']];
104+
if (isset($response['Response Code']) && isset($response_codes[$response['Response Code']])) {
105+
$response['Response Code'] = $response_codes[$response['Response Code']];
106+
} else {
107+
$response['Response Code'] = null;
108+
}
109+
110+
if (isset($response['AVS Response']) && isset($avs_response_codes[$response['AVS Response']])) {
111+
$response['AVS Response'] = $avs_response_codes[$response['AVS Response']];
112+
} else {
113+
$response['AVS Response'] = null;
114+
}
98115

99116
$this->data = $response;
100117

tests/Message/AIMResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class AIMResponseTest extends TestCase
88
{
99
/**
10-
* @expectedException Omnipay\Common\Exception\InvalidResponseException
10+
* @expectedException \Omnipay\Common\Exception\InvalidResponseException
1111
*/
1212
public function testConstructEmpty()
1313
{

0 commit comments

Comments
 (0)