@@ -63,14 +63,36 @@ 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/json ' , $ client ->getRequest ()->getServer ()['CONTENT_TYPE ' ]);
79
+ $ this ->assertSame ('application/json ' , $ client ->getRequest ()->getServer ()['HTTP_ACCEPT ' ]);
80
+ $ this ->assertSame ('application/xml ' , $ client ->getServerParameter ('HTTP_ACCEPT ' ));
81
+ $ this ->assertSame ('application/xml ' , $ client ->getServerParameter ('CONTENT_TYPE ' ));
82
+ }
83
+
84
+ public function testJsonRequestGet ()
85
+ {
86
+ $ client = $ this ->getBrowser ();
87
+ $ client ->jsonRequest ('GET ' , 'http://example.com/ ' , ['param ' => 1 ], [], true );
88
+ $ this ->assertSame ('application/json ' , $ client ->getRequest ()->getServer ()['CONTENT_TYPE ' ]);
89
+ $ this ->assertSame ('application/json ' , $ client ->getRequest ()->getServer ()['HTTP_ACCEPT ' ]);
90
+ $ this ->assertFalse ($ client ->getServerParameter ('CONTENT_TYPE ' , false ));
91
+ $ this ->assertFalse ($ client ->getServerParameter ('HTTP_ACCEPT ' , false ));
92
+ $ this ->assertNull ($ client ->getRequest ()->getContent ());
93
+ $ this ->assertSame (['param ' => '1 ' ], $ client ->getRequest ()->getParameters ());
94
+ }
95
+
74
96
public function testGetRequestWithIpAsHttpHost ()
75
97
{
76
98
$ client = $ this ->getBrowser ();
0 commit comments