@@ -644,31 +644,40 @@ public function testPostCurlFileFormDataContentType()
644
644
645
645
public function testJSONRequest ()
646
646
{
647
- $ data = array ('key ' => 'value ' );
648
- $ expected_response = '{"key":"value"} ' ;
647
+ foreach (
648
+ array (
649
+ array (
650
+ array (
651
+ 'key ' => 'value ' ,
652
+ ),
653
+ '{"key":"value"} ' ,
654
+ ),
655
+ ) as $ test ) {
656
+ list ($ data , $ expected_response ) = $ test ;
649
657
650
- $ test = new Test ();
651
- $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , json_encode ($ data )));
658
+ $ test = new Test ();
659
+ $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , json_encode ($ data )));
652
660
653
- foreach (array (
654
- 'Content-Type ' ,
655
- 'content-type ' ,
656
- 'CONTENT-TYPE ' ) as $ key ) {
657
661
foreach (array (
658
- 'APPLICATION/JSON ' ,
659
- 'APPLICATION/JSON; CHARSET=UTF-8 ' ,
660
- 'APPLICATION/JSON;CHARSET=UTF-8 ' ,
661
- 'application/json ' ,
662
- 'application/json; charset=utf-8 ' ,
663
- 'application/json;charset=UTF-8 ' ,
664
- ) as $ value ) {
665
- $ test = new Test ();
666
- $ test ->curl ->setHeader ($ key , $ value );
667
- $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , json_encode ($ data )));
668
-
669
- $ test = new Test ();
670
- $ test ->curl ->setHeader ($ key , $ value );
671
- $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , $ data ));
662
+ 'Content-Type ' ,
663
+ 'content-type ' ,
664
+ 'CONTENT-TYPE ' ) as $ key ) {
665
+ foreach (array (
666
+ 'APPLICATION/JSON ' ,
667
+ 'APPLICATION/JSON; CHARSET=UTF-8 ' ,
668
+ 'APPLICATION/JSON;CHARSET=UTF-8 ' ,
669
+ 'application/json ' ,
670
+ 'application/json; charset=utf-8 ' ,
671
+ 'application/json;charset=UTF-8 ' ,
672
+ ) as $ value ) {
673
+ $ test = new Test ();
674
+ $ test ->curl ->setHeader ($ key , $ value );
675
+ $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , json_encode ($ data )));
676
+
677
+ $ test = new Test ();
678
+ $ test ->curl ->setHeader ($ key , $ value );
679
+ $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , $ data ));
680
+ }
672
681
}
673
682
}
674
683
}
0 commit comments