|
6 | 6 | use Akeneo\Pim\ApiClient\Exception\ClientErrorHttpException; |
7 | 7 | use Akeneo\Pim\ApiClient\Exception\ForbiddenHttpException; |
8 | 8 | use Akeneo\Pim\ApiClient\Exception\MethodNotAllowedHttpException; |
| 9 | +use Akeneo\Pim\ApiClient\Exception\NotAcceptableHttpException; |
9 | 10 | use Akeneo\Pim\ApiClient\Exception\NotFoundHttpException; |
10 | 11 | use Akeneo\Pim\ApiClient\Exception\RedirectionHttpException; |
11 | 12 | use Akeneo\Pim\ApiClient\Exception\ServerErrorHttpException; |
@@ -149,6 +150,31 @@ function it_throws_method_not_allowed_exception_when_status_code_405( |
149 | 150 | ->during('transformResponseToException', [$request, $response]); |
150 | 151 | } |
151 | 152 |
|
| 153 | + function it_throws_method_not_allowed_exception_when_status_code_406( |
| 154 | + RequestInterface $request, |
| 155 | + ResponseInterface $response, |
| 156 | + StreamInterface $responseBody |
| 157 | + ) { |
| 158 | + $response->getStatusCode()->willReturn(406); |
| 159 | + $response->getBody()->willReturn($responseBody); |
| 160 | + $responseBody->getContents()->willReturn(<<<JSON |
| 161 | + { |
| 162 | + "code": 406, |
| 163 | + "message": "‘xxx’ in ‘Accept‘ header is not valid. Only ‘application/json‘ is allowed." |
| 164 | + } |
| 165 | + JSON); |
| 166 | + $responseBody->rewind()->shouldBeCalled(); |
| 167 | + $this |
| 168 | + ->shouldThrow( |
| 169 | + new NotAcceptableHttpException( |
| 170 | + '‘xxx’ in ‘Accept‘ header is not valid. Only ‘application/json‘ is allowed.', |
| 171 | + $request->getWrappedObject(), |
| 172 | + $response->getWrappedObject() |
| 173 | + ) |
| 174 | + ) |
| 175 | + ->during('transformResponseToException', [$request, $response]); |
| 176 | + } |
| 177 | + |
152 | 178 | function it_throws_bad_request_exception_when_status_code_422( |
153 | 179 | RequestInterface $request, |
154 | 180 | ResponseInterface $response, |
|
0 commit comments