@@ 151-168 (lines=18) @@ | ||
148 | expect($http->getRequests())->toHaveCount(1); |
|
149 | } |
|
150 | ||
151 | public function it_processes_xml_error_responses() |
|
152 | { |
|
153 | $http = $this->let(); |
|
154 | ||
155 | $exception = SpecHelper::makeExceptionResponse( |
|
156 | SpecHelper::getDummyData('error_response.xml', false), |
|
157 | 400, |
|
158 | 'application/xml;charset=utf-8' |
|
159 | ); |
|
160 | $http->addException($exception); |
|
161 | ||
162 | $this->shouldThrow(new RequestFailed( |
|
163 | 'Mandatory field is missing: library', |
|
164 | '401664' |
|
165 | ))->during('getXML', ['/items/123']); |
|
166 | ||
167 | expect($http->getRequests())->toHaveCount(1); |
|
168 | } |
|
169 | ||
170 | public function it_can_throw_resource_not_found() |
|
171 | { |
|
@@ 204-219 (lines=16) @@ | ||
201 | expect($http->getRequests())->toHaveCount(1); |
|
202 | } |
|
203 | ||
204 | public function it_can_throw_invalid_api_key() |
|
205 | { |
|
206 | $http = $this->let(); |
|
207 | ||
208 | $exception = SpecHelper::makeExceptionResponse( |
|
209 | 'Invalid API Key', |
|
210 | 400, |
|
211 | 'text/plain;charset=UTF-8' |
|
212 | ); |
|
213 | $http->addException($exception); |
|
214 | ||
215 | $this->shouldThrow(new InvalidApiKey('Invalid API Key', 0)) |
|
216 | ->during('getJSON', ['/items/123']); |
|
217 | ||
218 | expect($http->getRequests())->toHaveCount(1); |
|
219 | } |
|
220 | ||
221 | public function it_will_retry_when_reaching_rate_limit() |
|
222 | { |