[BrowserKit] add a way to switch to ajax for one request
This commit is contained in:
parent
b0facfec01
commit
a10eae7d9e
@ -150,6 +150,16 @@ abstract class Client
|
||||
return isset($this->server[$key]) ? $this->server[$key] : $default;
|
||||
}
|
||||
|
||||
public function switchToXHR()
|
||||
{
|
||||
$this->setServerParameter('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest');
|
||||
}
|
||||
|
||||
public function removeXHR()
|
||||
{
|
||||
unset($this->server['HTTP_X_REQUESTED_WITH']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the History instance.
|
||||
*
|
||||
|
@ -94,6 +94,16 @@ class ClientTest extends TestCase
|
||||
$this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
|
||||
}
|
||||
|
||||
public function testGetRequestWithXHR()
|
||||
{
|
||||
$client = new TestClient();
|
||||
$client->switchToXHR();
|
||||
$client->request('GET', 'http://example.com/', array(), array(), array(), null, true, true);
|
||||
$this->assertEquals($client->getRequest()->getServer()['HTTP_X_REQUESTED_WITH'], 'XMLHttpRequest');
|
||||
$client->removeXHR();
|
||||
$this->assertFalse($client->getServerParameter('HTTP_X_REQUESTED_WITH', false));
|
||||
}
|
||||
|
||||
public function testGetRequestWithIpAsHttpHost()
|
||||
{
|
||||
$client = new TestClient();
|
||||
|
Reference in New Issue
Block a user