[BrowserKit] Allow Referer set by history to be overridden (3.4)
This commit is contained in:
parent
048e6f3dd8
commit
4774946fbd
@ -294,7 +294,7 @@ abstract class Client
|
|||||||
$uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
|
$uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->history->isEmpty()) {
|
if (!isset($server['HTTP_REFERER']) && !$this->history->isEmpty()) {
|
||||||
$server['HTTP_REFERER'] = $this->history->current()->getUri();
|
$server['HTTP_REFERER'] = $this->history->current()->getUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,6 +233,15 @@ class ClientTest extends TestCase
|
|||||||
$this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer');
|
$this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRequestRefererCanBeOverridden()
|
||||||
|
{
|
||||||
|
$client = new TestClient();
|
||||||
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||||
|
$client->request('GET', 'bar', [], [], ['HTTP_REFERER' => 'xyz']);
|
||||||
|
$server = $client->getRequest()->getServer();
|
||||||
|
$this->assertEquals('xyz', $server['HTTP_REFERER'], '->request() allows referer to be overridden');
|
||||||
|
}
|
||||||
|
|
||||||
public function testRequestHistory()
|
public function testRequestHistory()
|
||||||
{
|
{
|
||||||
$client = new TestClient();
|
$client = new TestClient();
|
||||||
|
Reference in New Issue
Block a user