File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -503,4 +503,36 @@ public function testStreamCAFile()
503
503
504
504
}
505
505
506
+ /**
507
+ * @group bad-api-response
508
+ */
509
+ public function testBadApiResponse ()
510
+ {
511
+ $ this ->setExpectedException (ParseException::class,
512
+ 'Bad Request. Could not decode Response: (4) Syntax error ' );
513
+
514
+ $ httpClient = ParseClient::getHttpClient ();
515
+
516
+ // create a mock of the current http client
517
+ $ stubClient = $ this ->createMock (get_class ($ httpClient ));
518
+
519
+ // stub the response type to return
520
+ // something we will try to work with
521
+ $ stubClient
522
+ ->method ('getResponseContentType ' )
523
+ ->willReturn ('application/octet-stream ' );
524
+
525
+ $ stubClient
526
+ ->method ('send ' )
527
+ ->willReturn ('This is not valid json! ' );
528
+
529
+ // replace the client with our stub
530
+ ParseClient::setHttpClient ($ stubClient );
531
+
532
+ // attempt to save, which should not fire our given code
533
+ $ obj = new ParseObject ('TestingClass ' );
534
+ $ obj ->save ();
535
+
536
+ }
537
+
506
538
}
You can’t perform that action at this time.
0 commit comments