Skip to content

Commit d98aab3

Browse files
committed
[TASK] Add missing test for status code >= 400
1 parent 1775300 commit d98aab3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/Unit/Client/RestClientTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,32 @@ public function errorMessageIsCorrectGivenWhenAuthenticationError(): void
233233
new RestClient(self::$configuration);
234234
}
235235

236+
/**
237+
* @test
238+
*/
239+
public function errorMessageIsCorrectGivenWhenRequestError(): void
240+
{
241+
$this->expectException(HttpException::class);
242+
$this->expectExceptionCode(404);
243+
$this->expectExceptionMessage('Error fetching route some/route: Some error occured.');
244+
245+
$this->setResponseOfTokensPath();
246+
247+
self::$server->setResponseOfPath(
248+
'/api/rest/v2/some/route',
249+
new Response(
250+
\sprintf(
251+
'{"errors":{"-": ["%s"]}}',
252+
'Some error occured.'
253+
),
254+
['content-type' => 'application/json'],
255+
404
256+
)
257+
);
258+
259+
(new RestClient(self::$configuration))->request('GET', 'some/route');
260+
}
261+
236262
/**
237263
* @test
238264
*/

0 commit comments

Comments
 (0)