@@ -242,36 +242,48 @@ public function test_prevents_trailing_slash()
242242 }
243243
244244 /**
245- * Accept any 2xx status codes, throw an exception otherwise
245+ * Accept any 2xx status codes
246246 */
247- public function test_response_status_parsing ()
247+ public function test_success_response_status_parsing ()
248248 {
249249 for ($ i = 0 ; $ i < 10 ; $ i ++) {
250250 $ container = [];
251251 $ client = $ this ->getClientWithResponses ([
252252 new Response (rand (200 , 299 ), [], 'foo ' )
253253 ], $ container );
254254
255- $ response = $ client ->get ('test/uri ' ,['query ' => ['foo ' => true , 'bar ' => false ]]);
255+ $ response = $ client ->get ('test/uri ' , ['query ' => ['foo ' => true , 'bar ' => false ]]);
256256
257257 $ this ->assertEquals ('foo ' , $ response );
258258 }
259-
259+ }
260+
261+ public function errorCodeProvider ()
262+ {
263+ $ data = [];
260264 for ($ i = 0 ; $ i < 10 ; $ i ++) {
261265 $ status_code = rand (100 , 550 );
262266 if ($ status_code >= 200 && $ status_code <=299 ) {
263267 $ status_code += 100 ;
264268 }
269+ $ data [] = [$ status_code ];
270+ }
271+ return $ data ;
272+ }
273+
274+ /**
275+ * @dataProvider errorCodeProvider
276+ */
277+ public function test_error_response_status_parsing ($ status_code )
278+ {
279+ $ container = [];
280+ $ client = $ this ->getClientWithResponses ([
281+ new Response ($ status_code , [], 'foo ' )
282+ ], $ container );
265283
266- $ container = [];
267- $ client = $ this ->getClientWithResponses ([
268- new Response ($ status_code , [], 'foo ' )
269- ], $ container );
270-
271- $ this ->setExpectedException ('Interfax\Exception\RequestException ' , 'Unsuccessful request: foo ' );
284+ $ this ->setExpectedException ('Interfax\Exception\RequestException ' , 'Unsuccessful request: foo ' );
272285
273- $ response = $ client ->get ('test/uri ' ,['query ' => ['foo ' => true , 'bar ' => false ]]);
274- }
286+ $ response = $ client ->get ('test/uri ' , ['query ' => ['foo ' => true , 'bar ' => false ]]);
275287 }
276288
277289}
0 commit comments