@@ -644,31 +644,51 @@ 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
+ array (
656
+ array (
657
+ 'key ' => 'value ' ,
658
+ 'strings ' => array (
659
+ 'a ' ,
660
+ 'b ' ,
661
+ 'c ' ,
662
+ ),
663
+ ),
664
+ '{"key":"value","strings":["a","b","c"]} ' ,
665
+ ),
666
+ ) as $ test ) {
667
+ list ($ data , $ expected_response ) = $ test ;
649
668
650
- $ test = new Test ();
651
- $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , json_encode ($ data )));
669
+ $ test = new Test ();
670
+ $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , json_encode ($ data )));
652
671
653
- foreach (array (
654
- 'Content-Type ' ,
655
- 'content-type ' ,
656
- 'CONTENT-TYPE ' ) as $ key ) {
657
672
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 ));
673
+ 'Content-Type ' ,
674
+ 'content-type ' ,
675
+ 'CONTENT-TYPE ' ) as $ key ) {
676
+ foreach (array (
677
+ 'APPLICATION/JSON ' ,
678
+ 'APPLICATION/JSON; CHARSET=UTF-8 ' ,
679
+ 'APPLICATION/JSON;CHARSET=UTF-8 ' ,
680
+ 'application/json ' ,
681
+ 'application/json; charset=utf-8 ' ,
682
+ 'application/json;charset=UTF-8 ' ,
683
+ ) as $ value ) {
684
+ $ test = new Test ();
685
+ $ test ->curl ->setHeader ($ key , $ value );
686
+ $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , json_encode ($ data )));
687
+
688
+ $ test = new Test ();
689
+ $ test ->curl ->setHeader ($ key , $ value );
690
+ $ this ->assertEquals ($ expected_response , $ test ->server ('post_json ' , 'POST ' , $ data ));
691
+ }
672
692
}
673
693
}
674
694
}
0 commit comments