Skip to content

Commit 96c7bf7

Browse files
committed
Fix undefined status_code
1 parent 33abf63 commit 96c7bf7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/PrestashopWebServiceLibrary.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected function checkRequest($request)
9797
throw new PrestashopWebServiceRequestException($messages[$request['status_code']], $request['status_code'], $xml);
9898
} else {
9999
$exception = 'This call to PrestaShop Web Services returned an unexpected HTTP status of: ';
100-
$exception.= $status_code;
100+
$exception.= $request['status_code'];
101101
throw new PrestashopWebServiceException($exception);
102102
}
103103
}

tests/PrestashopWebServiceTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ public function it_throws_exception_on_404()
5454
}
5555
}
5656

57+
/** @test */
58+
public function it_throws_exception_on_unknown_http_status()
59+
{
60+
$ps = $this->getMockedLibrary('executeRequest', [
61+
'status_code' => 999,
62+
'response' => '<?xml version="1.0" encoding="UTF-8"?>
63+
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
64+
</prestashop>',
65+
'header' => ''
66+
]);
67+
68+
$this->expectExceptionMessage('unexpected HTTP status of: 999', PrestashopWebServiceException::class);
69+
$xml = $ps->get(['resource' => 'categories']);
70+
}
71+
5772
/** @test */
5873
public function it_throws_exception_on_empty_response()
5974
{

0 commit comments

Comments
 (0)