@@ -46,30 +46,22 @@ public function testCaseInsensitiveArrayGet()
46
46
47
47
public function testCaseInsensitiveArraySet ()
48
48
{
49
- function assertions ($ array , $ count = 1 )
50
- {
51
- PHPUnit_Framework_Assert::assertCount ($ count , $ array );
52
- PHPUnit_Framework_Assert::assertEquals ('bar ' , $ array ['foo ' ]);
53
- PHPUnit_Framework_Assert::assertEquals ('bar ' , $ array ['Foo ' ]);
54
- PHPUnit_Framework_Assert::assertEquals ('bar ' , $ array ['FOo ' ]);
55
- PHPUnit_Framework_Assert::assertEquals ('bar ' , $ array ['FOO ' ]);
56
- }
57
-
58
49
$ array = new CaseInsensitiveArray ();
59
- $ array ['foo ' ] = 'bar ' ;
60
- assertions ($ array );
61
-
62
- $ array ['Foo ' ] = 'bar ' ;
63
- assertions ($ array );
64
-
65
- $ array ['FOo ' ] = 'bar ' ;
66
- assertions ($ array );
67
-
68
- $ array ['FOO ' ] = 'bar ' ;
69
- assertions ($ array );
50
+ foreach (array ('FOO ' , 'FOo ' , 'Foo ' , 'fOO ' , 'fOo ' , 'foO ' , 'foo ' ) as $ key ) {
51
+ $ value = mt_rand ();
52
+ $ array [$ key ] = $ value ;
53
+ $ this ->assertCount (1 , $ array );
54
+ $ this ->assertEquals ($ value , $ array ['FOO ' ]);
55
+ $ this ->assertEquals ($ value , $ array ['FOo ' ]);
56
+ $ this ->assertEquals ($ value , $ array ['Foo ' ]);
57
+ $ this ->assertEquals ($ value , $ array ['fOO ' ]);
58
+ $ this ->assertEquals ($ value , $ array ['fOo ' ]);
59
+ $ this ->assertEquals ($ value , $ array ['foO ' ]);
60
+ $ this ->assertEquals ($ value , $ array ['foo ' ]);
61
+ }
70
62
71
63
$ array ['baz ' ] = 'qux ' ;
72
- assertions ( $ array , 2 );
64
+ $ this -> assertCount ( 2 , $ array );
73
65
}
74
66
75
67
public function testUserAgent ()
@@ -213,7 +205,8 @@ public function testPostAssociativeArrayData()
213
205
public function testPostMultidimensionalData ()
214
206
{
215
207
$ test = new Test ();
216
- $ this ->assertEquals ('key=file&file%5B%5D=wibble&file%5B%5D=wubble&file%5B%5D=wobble ' ,
208
+ $ this ->assertEquals (
209
+ 'key=file&file%5B%5D=wibble&file%5B%5D=wubble&file%5B%5D=wobble ' ,
217
210
$ test ->server ('post_multidimensional ' , 'POST ' , array (
218
211
'key ' => 'file ' ,
219
212
'file ' => array (
@@ -682,122 +675,92 @@ public function testJSONRequest()
682
675
683
676
public function testJSONResponse ()
684
677
{
685
- function assertion ($ key , $ value )
686
- {
687
- $ test = new Test ();
688
- $ test ->server ('json_response ' , 'POST ' , array (
689
- 'key ' => $ key ,
690
- 'value ' => $ value ,
691
- ));
692
-
693
- $ response = $ test ->curl ->response ;
694
- PHPUnit_Framework_Assert::assertNotNull ($ response );
695
- PHPUnit_Framework_Assert::assertNull ($ response ->null );
696
- PHPUnit_Framework_Assert::assertTrue ($ response ->true );
697
- PHPUnit_Framework_Assert::assertFalse ($ response ->false );
698
- PHPUnit_Framework_Assert::assertTrue (is_int ($ response ->integer ));
699
- PHPUnit_Framework_Assert::assertTrue (is_float ($ response ->float ));
700
- PHPUnit_Framework_Assert::assertEmpty ($ response ->empty );
701
- PHPUnit_Framework_Assert::assertTrue (is_string ($ response ->string ));
702
- PHPUnit_Framework_Assert::assertEquals (json_encode (array (
703
- 'null ' => null ,
704
- 'true ' => true ,
705
- 'false ' => false ,
706
- 'integer ' => 1 ,
707
- 'float ' => 3.14 ,
708
- 'empty ' => '' ,
709
- 'string ' => 'string ' ,
710
- )), $ test ->curl ->raw_response );
678
+ foreach (array (
679
+ 'Content-Type ' ,
680
+ 'content-type ' ,
681
+ 'CONTENT-TYPE ' ) as $ key ) {
682
+ foreach (array (
683
+ 'APPLICATION/JSON ' ,
684
+ 'APPLICATION/JSON; CHARSET=UTF-8 ' ,
685
+ 'APPLICATION/JSON;CHARSET=UTF-8 ' ,
686
+ 'application/json ' ,
687
+ 'application/json; charset=utf-8 ' ,
688
+ 'application/json;charset=UTF-8 ' ,
689
+ ) as $ value ) {
690
+ $ test = new Test ();
691
+ $ test ->server ('json_response ' , 'POST ' , array (
692
+ 'key ' => $ key ,
693
+ 'value ' => $ value ,
694
+ ));
695
+
696
+ $ response = $ test ->curl ->response ;
697
+ $ this ->assertNotNull ($ response );
698
+ $ this ->assertNull ($ response ->null );
699
+ $ this ->assertTrue ($ response ->true );
700
+ $ this ->assertFalse ($ response ->false );
701
+ $ this ->assertTrue (is_int ($ response ->integer ));
702
+ $ this ->assertTrue (is_float ($ response ->float ));
703
+ $ this ->assertEmpty ($ response ->empty );
704
+ $ this ->assertTrue (is_string ($ response ->string ));
705
+ $ this ->assertEquals (json_encode (array (
706
+ 'null ' => null ,
707
+ 'true ' => true ,
708
+ 'false ' => false ,
709
+ 'integer ' => 1 ,
710
+ 'float ' => 3.14 ,
711
+ 'empty ' => '' ,
712
+ 'string ' => 'string ' ,
713
+ )), $ test ->curl ->raw_response );
714
+ }
711
715
}
712
-
713
- assertion ('Content-Type ' , 'APPLICATION/JSON ' );
714
- assertion ('Content-Type ' , 'APPLICATION/JSON; CHARSET=UTF-8 ' );
715
- assertion ('Content-Type ' , 'APPLICATION/JSON;CHARSET=UTF-8 ' );
716
- assertion ('Content-Type ' , 'application/json ' );
717
- assertion ('Content-Type ' , 'application/json; charset=utf-8 ' );
718
- assertion ('Content-Type ' , 'application/json;charset=UTF-8 ' );
719
-
720
- assertion ('content-type ' , 'APPLICATION/JSON ' );
721
- assertion ('content-type ' , 'APPLICATION/JSON; CHARSET=UTF-8 ' );
722
- assertion ('content-type ' , 'APPLICATION/JSON;CHARSET=UTF-8 ' );
723
- assertion ('content-type ' , 'application/json ' );
724
- assertion ('content-type ' , 'application/json; charset=utf-8 ' );
725
- assertion ('content-type ' , 'application/json;charset=UTF-8 ' );
726
-
727
- assertion ('CONTENT-TYPE ' , 'APPLICATION/JSON ' );
728
- assertion ('CONTENT-TYPE ' , 'APPLICATION/JSON; CHARSET=UTF-8 ' );
729
- assertion ('CONTENT-TYPE ' , 'APPLICATION/JSON;CHARSET=UTF-8 ' );
730
- assertion ('CONTENT-TYPE ' , 'application/json ' );
731
- assertion ('CONTENT-TYPE ' , 'application/json; charset=utf-8 ' );
732
- assertion ('CONTENT-TYPE ' , 'application/json;charset=UTF-8 ' );
733
716
}
734
717
735
718
public function testXMLResponse ()
736
719
{
737
- function xmlAssertion ($ key , $ value )
738
- {
739
- $ test = new Test ();
740
- $ test ->server ('xml_response ' , 'POST ' , array (
741
- 'key ' => $ key ,
742
- 'value ' => $ value ,
743
- ));
744
-
745
- PHPUnit_Framework_Assert::assertInstanceOf ('SimpleXMLElement ' , $ test ->curl ->response );
746
-
747
- $ doc = new DOMDocument ();
748
- $ doc ->formatOutput = true ;
749
- $ rss = $ doc ->appendChild ($ doc ->createElement ('rss ' ));
750
- $ rss ->setAttribute ('version ' , '2.0 ' );
751
- $ channel = $ doc ->createElement ('channel ' );
752
- $ title = $ doc ->createElement ('title ' );
753
- $ title ->appendChild ($ doc ->createTextNode ('Title ' ));
754
- $ channel ->appendChild ($ title );
755
- $ link = $ doc ->createElement ('link ' );
756
- $ link ->appendChild ($ doc ->createTextNode ('Link ' ));
757
- $ channel ->appendChild ($ link );
758
- $ description = $ doc ->createElement ('description ' );
759
- $ description ->appendChild ($ doc ->createTextNode ('Description ' ));
760
- $ channel ->appendChild ($ description );
761
- $ rss ->appendChild ($ channel );
762
- $ xml = $ doc ->saveXML ();
763
- PHPUnit_Framework_Assert::assertEquals ($ xml , $ test ->curl ->raw_response );
720
+ foreach (array (
721
+ 'Content-Type ' ,
722
+ 'content-type ' ,
723
+ 'CONTENT-TYPE ' ) as $ key ) {
724
+ foreach (array (
725
+ 'application/atom+xml; charset=UTF-8 ' ,
726
+ 'application/atom+xml;charset=UTF-8 ' ,
727
+ 'application/rss+xml ' ,
728
+ 'application/rss+xml; charset=utf-8 ' ,
729
+ 'application/rss+xml;charset=utf-8 ' ,
730
+ 'application/xml ' ,
731
+ 'application/xml; charset=utf-8 ' ,
732
+ 'application/xml;charset=utf-8 ' ,
733
+ 'text/xml ' ,
734
+ 'text/xml; charset=utf-8 ' ,
735
+ 'text/xml;charset=utf-8 ' ,
736
+ ) as $ value ) {
737
+ $ test = new Test ();
738
+ $ test ->server ('xml_response ' , 'POST ' , array (
739
+ 'key ' => $ key ,
740
+ 'value ' => $ value ,
741
+ ));
742
+
743
+ $ this ->assertInstanceOf ('SimpleXMLElement ' , $ test ->curl ->response );
744
+
745
+ $ doc = new DOMDocument ();
746
+ $ doc ->formatOutput = true ;
747
+ $ rss = $ doc ->appendChild ($ doc ->createElement ('rss ' ));
748
+ $ rss ->setAttribute ('version ' , '2.0 ' );
749
+ $ channel = $ doc ->createElement ('channel ' );
750
+ $ title = $ doc ->createElement ('title ' );
751
+ $ title ->appendChild ($ doc ->createTextNode ('Title ' ));
752
+ $ channel ->appendChild ($ title );
753
+ $ link = $ doc ->createElement ('link ' );
754
+ $ link ->appendChild ($ doc ->createTextNode ('Link ' ));
755
+ $ channel ->appendChild ($ link );
756
+ $ description = $ doc ->createElement ('description ' );
757
+ $ description ->appendChild ($ doc ->createTextNode ('Description ' ));
758
+ $ channel ->appendChild ($ description );
759
+ $ rss ->appendChild ($ channel );
760
+ $ xml = $ doc ->saveXML ();
761
+ $ this ->assertEquals ($ xml , $ test ->curl ->raw_response );
762
+ }
764
763
}
765
-
766
- xmlAssertion ('Content-Type ' , 'application/atom+xml; charset=UTF-8 ' );
767
- xmlAssertion ('Content-Type ' , 'application/atom+xml;charset=UTF-8 ' );
768
- xmlAssertion ('Content-Type ' , 'application/rss+xml ' );
769
- xmlAssertion ('Content-Type ' , 'application/rss+xml; charset=utf-8 ' );
770
- xmlAssertion ('Content-Type ' , 'application/rss+xml;charset=utf-8 ' );
771
- xmlAssertion ('Content-Type ' , 'application/xml ' );
772
- xmlAssertion ('Content-Type ' , 'application/xml; charset=utf-8 ' );
773
- xmlAssertion ('Content-Type ' , 'application/xml;charset=utf-8 ' );
774
- xmlAssertion ('Content-Type ' , 'text/xml ' );
775
- xmlAssertion ('Content-Type ' , 'text/xml; charset=utf-8 ' );
776
- xmlAssertion ('Content-Type ' , 'text/xml;charset=utf-8 ' );
777
-
778
- xmlAssertion ('content-type ' , 'application/atom+xml; charset=UTF-8 ' );
779
- xmlAssertion ('content-type ' , 'application/atom+xml;charset=UTF-8 ' );
780
- xmlAssertion ('content-type ' , 'application/rss+xml ' );
781
- xmlAssertion ('content-type ' , 'application/rss+xml; charset=utf-8 ' );
782
- xmlAssertion ('content-type ' , 'application/rss+xml;charset=utf-8 ' );
783
- xmlAssertion ('content-type ' , 'application/xml ' );
784
- xmlAssertion ('content-type ' , 'application/xml; charset=utf-8 ' );
785
- xmlAssertion ('content-type ' , 'application/xml;charset=utf-8 ' );
786
- xmlAssertion ('content-type ' , 'text/xml ' );
787
- xmlAssertion ('content-type ' , 'text/xml; charset=utf-8 ' );
788
- xmlAssertion ('content-type ' , 'text/xml;charset=utf-8 ' );
789
-
790
- xmlAssertion ('CONTENT-TYPE ' , 'application/atom+xml; charset=UTF-8 ' );
791
- xmlAssertion ('CONTENT-TYPE ' , 'application/atom+xml;charset=UTF-8 ' );
792
- xmlAssertion ('CONTENT-TYPE ' , 'application/rss+xml ' );
793
- xmlAssertion ('CONTENT-TYPE ' , 'application/rss+xml; charset=utf-8 ' );
794
- xmlAssertion ('CONTENT-TYPE ' , 'application/rss+xml;charset=utf-8 ' );
795
- xmlAssertion ('CONTENT-TYPE ' , 'application/xml ' );
796
- xmlAssertion ('CONTENT-TYPE ' , 'application/xml; charset=utf-8 ' );
797
- xmlAssertion ('CONTENT-TYPE ' , 'application/xml;charset=utf-8 ' );
798
- xmlAssertion ('CONTENT-TYPE ' , 'text/xml ' );
799
- xmlAssertion ('CONTENT-TYPE ' , 'text/xml; charset=utf-8 ' );
800
- xmlAssertion ('CONTENT-TYPE ' , 'text/xml;charset=utf-8 ' );
801
764
}
802
765
803
766
public function testEmptyResponse ()
@@ -1049,8 +1012,8 @@ public function testParallelSuccessCallback()
1049
1012
Test::TEST_URL . 'c/ ' ,
1050
1013
));
1051
1014
1052
- PHPUnit_Framework_Assert:: assertTrue ($ success_called_once || $ error_called_once );
1053
- PHPUnit_Framework_Assert:: assertTrue ($ complete_called_once );
1015
+ $ this -> assertTrue ($ success_called_once || $ error_called_once );
1016
+ $ this -> assertTrue ($ complete_called_once );
1054
1017
}
1055
1018
1056
1019
public function testErrorCallback ()
0 commit comments