| @@ 143-160 (lines=18) @@ | ||
| 140 | expect($http->getRequests())->toHaveCount(1); | |
| 141 | } | |
| 142 | ||
| 143 | public function it_processes_xml_error_responses() | |
| 144 |     { | |
| 145 | $http = $this->let(); | |
| 146 | ||
| 147 | $exception = SpecHelper::makeExceptionResponse( | |
| 148 |             SpecHelper::getDummyData('error_response.xml', false), | |
| 149 | 400, | |
| 150 | 'application/xml;charset=utf-8' | |
| 151 | ); | |
| 152 | $http->addException($exception); | |
| 153 | ||
| 154 | $this->shouldThrow(new RequestFailed( | |
| 155 | 'Mandatory field is missing: library', | |
| 156 | '401664' | |
| 157 |         ))->during('getXML', ['/items/123']); | |
| 158 | ||
| 159 | expect($http->getRequests())->toHaveCount(1); | |
| 160 | } | |
| 161 | ||
| 162 | public function it_can_throw_resource_not_found() | |
| 163 |     { | |
| @@ 196-211 (lines=16) @@ | ||
| 193 | expect($http->getRequests())->toHaveCount(1); | |
| 194 | } | |
| 195 | ||
| 196 | public function it_can_throw_invalid_api_key() | |
| 197 |     { | |
| 198 | $http = $this->let(); | |
| 199 | ||
| 200 | $exception = SpecHelper::makeExceptionResponse( | |
| 201 | 'Invalid API Key', | |
| 202 | 400, | |
| 203 | 'text/plain;charset=UTF-8' | |
| 204 | ); | |
| 205 | $http->addException($exception); | |
| 206 | ||
| 207 |         $this->shouldThrow(new InvalidApiKey('Invalid API Key', 0)) | |
| 208 |            ->during('getJSON', ['/items/123']); | |
| 209 | ||
| 210 | expect($http->getRequests())->toHaveCount(1); | |
| 211 | } | |
| 212 | ||
| 213 | public function it_will_retry_when_reaching_rate_limit() | |
| 214 |     { | |