$this->
expectException(BadMethodCallException::
class);
$this->
expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getRequest()".'
);
$client =
$this->
getBrowser();
$this->
assertNull($client->
getRequest());
} public function testXmlHttpRequest() { $client =
$this->
getBrowser();
$client->
xmlHttpRequest('GET', 'http://example.com/',
[],
[],
[], null, true
);
$this->
assertSame('XMLHttpRequest',
$client->
getRequest()->
getServer()['HTTP_X_REQUESTED_WITH'
]);
$this->
assertFalse($client->
getServerParameter('HTTP_X_REQUESTED_WITH', false
));
} public function testJsonRequest() { $client =
$this->
getBrowser();
$client->
jsonRequest('GET', 'http://example.com/',
['param' => 1
],
[], true
);
$this->
assertSame('application/json',
$client->
getRequest()->
getServer()['CONTENT_TYPE'
]);
$this->
assertSame('application/json',
$client->
getRequest()->
getServer()['HTTP_ACCEPT'
]);
$this->
assertFalse($client->
getServerParameter('CONTENT_TYPE', false
));