@@ -63,14 +63,34 @@ public function testXmlHttpRequest()
63
63
public function testJsonRequest ()
64
64
{
65
65
$ client = $ this ->getBrowser ();
66
- $ client ->jsonRequest ('GET ' , 'http://example.com/ ' , ['param ' => 1 ], [], true );
66
+ $ client ->jsonRequest ('POST ' , 'http://example.com/ ' , ['param ' => 1 ], [], true );
67
67
$ this ->assertSame ('application/json ' , $ client ->getRequest ()->getServer ()['CONTENT_TYPE ' ]);
68
68
$ this ->assertSame ('application/json ' , $ client ->getRequest ()->getServer ()['HTTP_ACCEPT ' ]);
69
69
$ this ->assertFalse ($ client ->getServerParameter ('CONTENT_TYPE ' , false ));
70
70
$ this ->assertFalse ($ client ->getServerParameter ('HTTP_ACCEPT ' , false ));
71
71
$ this ->assertSame ('{"param":1} ' , $ client ->getRequest ()->getContent ());
72
72
}
73
73
74
+ public function testJsonRequestPredefinedServerVariables ()
75
+ {
76
+ $ client = $ this ->getBrowser (['HTTP_ACCEPT ' => 'application/xml ' , 'CONTENT_TYPE ' => 'application/xml ' ]);
77
+ $ client ->jsonRequest ('POST ' , 'http://example.com/ ' , ['param ' => 1 ], [], true );
78
+ $ this ->assertSame ('application/xml ' , $ client ->getServerParameter ('HTTP_ACCEPT ' ));
79
+ $ this ->assertSame ('application/xml ' , $ client ->getServerParameter ('CONTENT_TYPE ' ));
80
+ }
81
+
82
+ public function testJsonRequestGet ()
83
+ {
84
+ $ client = $ this ->getBrowser ();
85
+ $ client ->jsonRequest ('GET ' , 'http://example.com/ ' , ['param ' => 1 ], [], true );
86
+ $ this ->assertSame ('application/json ' , $ client ->getRequest ()->getServer ()['CONTENT_TYPE ' ]);
87
+ $ this ->assertSame ('application/json ' , $ client ->getRequest ()->getServer ()['HTTP_ACCEPT ' ]);
88
+ $ this ->assertFalse ($ client ->getServerParameter ('CONTENT_TYPE ' , false ));
89
+ $ this ->assertFalse ($ client ->getServerParameter ('HTTP_ACCEPT ' , false ));
90
+ $ this ->assertSame (null , $ client ->getRequest ()->getContent ());
91
+ $ this ->assertSame (['param ' => '1 ' ], $ client ->getRequest ()->getParameters ());
92
+ }
93
+
74
94
public function testGetRequestWithIpAsHttpHost ()
75
95
{
76
96
$ client = $ this ->getBrowser ();
0 commit comments