|
@@ 115-132 (lines=18) @@
|
| 112 |
|
$this->getRedirectLocation('/')->shouldBe('http://test.test'); |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
public function it_processes_json_error_responses(ClientErrorException $exception) |
| 116 |
|
{ |
| 117 |
|
$exception->getResponse()->willReturn(new Response( |
| 118 |
|
400, |
| 119 |
|
['Content-Type' => 'application/json;charset=utf-8'], |
| 120 |
|
SpecHelper::getDummyData('error_response.json', false) |
| 121 |
|
)); |
| 122 |
|
|
| 123 |
|
$http = $this->let(); |
| 124 |
|
$http->addException($exception->getWrappedObject()); |
| 125 |
|
|
| 126 |
|
$this->shouldThrow(new RequestFailed( |
| 127 |
|
'Mandatory field is missing: library', |
| 128 |
|
'401664' |
| 129 |
|
))->during('getJSON', ['/items/123']); |
| 130 |
|
|
| 131 |
|
expect($http->getRequests())->toHaveCount(1); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
public function it_processes_xml_error_responses(ClientErrorException $exception) |
| 135 |
|
{ |
|
@@ 134-151 (lines=18) @@
|
| 131 |
|
expect($http->getRequests())->toHaveCount(1); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
public function it_processes_xml_error_responses(ClientErrorException $exception) |
| 135 |
|
{ |
| 136 |
|
$exception->getResponse()->willReturn(new Response( |
| 137 |
|
400, |
| 138 |
|
['Content-Type' => 'application/xml;charset=utf-8'], |
| 139 |
|
SpecHelper::getDummyData('error_response.xml', false) |
| 140 |
|
)); |
| 141 |
|
|
| 142 |
|
$http = $this->let(); |
| 143 |
|
$http->addException($exception->getWrappedObject()); |
| 144 |
|
|
| 145 |
|
$this->shouldThrow(new RequestFailed( |
| 146 |
|
'Mandatory field is missing: library', |
| 147 |
|
'401664' |
| 148 |
|
))->during('getXML', ['/items/123']); |
| 149 |
|
|
| 150 |
|
expect($http->getRequests())->toHaveCount(1); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
public function it_can_throw_resource_not_found(ClientErrorException $exception) |
| 154 |
|
{ |
|
@@ 153-168 (lines=16) @@
|
| 150 |
|
expect($http->getRequests())->toHaveCount(1); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
public function it_can_throw_resource_not_found(ClientErrorException $exception) |
| 154 |
|
{ |
| 155 |
|
$exception->getResponse()->willReturn(new Response( |
| 156 |
|
400, |
| 157 |
|
['Content-Type' => 'application/json;charset=utf-8'], |
| 158 |
|
SpecHelper::getDummyData('item_barcode_error_response.json', false) |
| 159 |
|
)); |
| 160 |
|
|
| 161 |
|
$http = $this->let(); |
| 162 |
|
$http->addException($exception->getWrappedObject()); |
| 163 |
|
|
| 164 |
|
$this->shouldThrow(new ResourceNotFound('No items found for barcode 123.', '401689')) |
| 165 |
|
->during('getJSON', ['/items/123']); |
| 166 |
|
|
| 167 |
|
expect($http->getRequests())->toHaveCount(1); |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
public function it_can_throw_invalid_api_key(ClientErrorException $exception) |
| 171 |
|
{ |
|
@@ 170-185 (lines=16) @@
|
| 167 |
|
expect($http->getRequests())->toHaveCount(1); |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
public function it_can_throw_invalid_api_key(ClientErrorException $exception) |
| 171 |
|
{ |
| 172 |
|
$exception->getResponse()->willReturn(new Response( |
| 173 |
|
400, |
| 174 |
|
['Content-Type' => 'text/plain;charset=UTF-8'], |
| 175 |
|
'Invalid API Key' |
| 176 |
|
)); |
| 177 |
|
|
| 178 |
|
$http = $this->let(); |
| 179 |
|
$http->addException($exception->getWrappedObject()); |
| 180 |
|
|
| 181 |
|
$this->shouldThrow(new InvalidApiKey('Invalid API Key', 0)) |
| 182 |
|
->during('getJSON', ['/items/123']); |
| 183 |
|
|
| 184 |
|
expect($http->getRequests())->toHaveCount(1); |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
public function it_will_retry_when_reaching_rate_limit(ClientErrorException $exception) |
| 188 |
|
{ |