|
4 | 4 |
|
5 | 5 | use Akeneo\Pim\ApiClient\Exception\BadRequestHttpException; |
6 | 6 | use Akeneo\Pim\ApiClient\Exception\ClientErrorHttpException; |
| 7 | +use Akeneo\Pim\ApiClient\Exception\ForbiddenHttpException; |
7 | 8 | use Akeneo\Pim\ApiClient\Exception\NotFoundHttpException; |
8 | 9 | use Akeneo\Pim\ApiClient\Exception\RedirectionHttpException; |
9 | 10 | use Akeneo\Pim\ApiClient\Exception\ServerErrorHttpException; |
@@ -82,6 +83,26 @@ function it_throws_unauthorized_request_exception_when_status_code_401( |
82 | 83 | ->during('transformResponseToException', [$request, $response]); |
83 | 84 | } |
84 | 85 |
|
| 86 | + function it_throws_forbidden_exception_when_status_code_403( |
| 87 | + RequestInterface $request, |
| 88 | + ResponseInterface $response, |
| 89 | + StreamInterface $responseBody |
| 90 | + ) { |
| 91 | + $response->getStatusCode()->willReturn(403); |
| 92 | + $response->getBody()->willReturn($responseBody); |
| 93 | + $responseBody->getContents()->willReturn('{"code": 403, "message": "Access forbidden."}'); |
| 94 | + $responseBody->rewind()->shouldBeCalled(); |
| 95 | + $this |
| 96 | + ->shouldThrow( |
| 97 | + new ForbiddenHttpException( |
| 98 | + 'Access forbidden.', |
| 99 | + $request->getWrappedObject(), |
| 100 | + $response->getWrappedObject() |
| 101 | + ) |
| 102 | + ) |
| 103 | + ->during('transformResponseToException', [$request, $response]); |
| 104 | + } |
| 105 | + |
85 | 106 | function it_throws_not_found_exception_when_status_code_404( |
86 | 107 | RequestInterface $request, |
87 | 108 | ResponseInterface $response, |
|
0 commit comments