@@ -233,13 +233,13 @@ public function testPushwooshCall()
233233 }
234234
235235 // Second test with a CURL error encountered
236- $ curlRequest = $ this ->createMock (CURLRequest ::class);
236+ $ curlRequest = $ this ->createMock (CurlRequest ::class);
237237 $ curlRequest ->method ('exec ' )->willReturn (
238- [
239- ' status_code ' => 400 ,
240- ' status_message ' => ' Test with valid JSON response but CURL error encountered. ' ,
241- ' response ' => null
242- ]
238+ ' {
239+ " status_code" : 400,
240+ " status_message" : " Test with valid JSON response but CURL error encountered." ,
241+ " response" : null
242+ } '
243243 );
244244 $ curlRequest ->method ('error ' )->willReturn ('CURL_ERROR ' );
245245 $ curlRequest ->method ('getInfo ' )->willReturn ('CURL_INFO ' );
@@ -272,13 +272,40 @@ public function testPushwooshCall()
272272 $ this ->assertSame ('CURL_ERROR ' , $ data ['curl_error ' ]);
273273 $ this ->assertSame ('CURL_INFO ' , $ data ['curl_info ' ]);
274274 $ this ->assertSame (
275- [
276- ' status_code ' => 400 ,
277- ' status_message ' => ' Test with valid JSON response but CURL error encountered. ' ,
278- ' response ' => null
279- ] ,
275+ ' {
276+ " status_code" : 400,
277+ " status_message" : " Test with valid JSON response but CURL error encountered." ,
278+ " response" : null
279+ } ' ,
280280 $ data ['response ' ]
281281 );
282282 }
283+
284+ // Thrird test with a valid call
285+ $ curlRequest = $ this ->createMock (CurlRequest::class);
286+ $ curlRequest ->method ('exec ' )->willReturn (
287+ '{
288+ "status_code" : 200,
289+ "status_message" : "OK"
290+ } '
291+ );
292+ $ curlRequest ->method ('error ' )->willReturn ('' );
293+ $ curlRequest ->method ('getInfo ' )->willReturn ('CURL_INFO ' );
294+
295+ $ curlClient ->setCurlRequest ($ curlRequest );
296+
297+ $ response = $ curlClient ->pushwooshCall (
298+ 'getTags ' ,
299+ [
300+ 'application ' => 'XXXXXXXX ' ,
301+ 'auth ' => 'XXXXXXXX ' ,
302+ 'hwid ' => 'XXXXXXXX '
303+ ]
304+ );
305+ $ this ->assertCount (2 , $ response );
306+ $ this ->assertArrayHasKey ('status_code ' , $ response );
307+ $ this ->assertSame (200 , $ response ['status_code ' ]);
308+ $ this ->assertArrayHasKey ('status_message ' , $ response );
309+ $ this ->assertSame ('OK ' , $ response ['status_message ' ]);
283310 }
284311}
0 commit comments