|
|
@ -75,21 +75,26 @@ EOF;
|
|
|
|
|
|
|
|
|
|
|
|
class AbstractBrowserTest extends TestCase
|
|
|
|
class AbstractBrowserTest extends TestCase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
public function getBrowser(array $server = [], History $history = null, CookieJar $cookieJar = null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new TestClient($server, $history, $cookieJar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetHistory()
|
|
|
|
public function testGetHistory()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient([], $history = new History());
|
|
|
|
$client = $this->getBrowser([], $history = new History());
|
|
|
|
$this->assertSame($history, $client->getHistory(), '->getHistory() returns the History');
|
|
|
|
$this->assertSame($history, $client->getHistory(), '->getHistory() returns the History');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetCookieJar()
|
|
|
|
public function testGetCookieJar()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient([], null, $cookieJar = new CookieJar());
|
|
|
|
$client = $this->getBrowser([], null, $cookieJar = new CookieJar());
|
|
|
|
$this->assertSame($cookieJar, $client->getCookieJar(), '->getCookieJar() returns the CookieJar');
|
|
|
|
$this->assertSame($cookieJar, $client->getCookieJar(), '->getCookieJar() returns the CookieJar');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetRequest()
|
|
|
|
public function testGetRequest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://example.com/');
|
|
|
|
$client->request('GET', 'http://example.com/');
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
|
|
|
|
$this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
|
|
|
@ -101,13 +106,13 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function testGetRequestNull()
|
|
|
|
public function testGetRequestNull()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$this->assertNull($client->getRequest());
|
|
|
|
$this->assertNull($client->getRequest());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testXmlHttpRequest()
|
|
|
|
public function testXmlHttpRequest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->xmlHttpRequest('GET', 'http://example.com/', [], [], [], null, true);
|
|
|
|
$client->xmlHttpRequest('GET', 'http://example.com/', [], [], [], null, true);
|
|
|
|
$this->assertEquals($client->getRequest()->getServer()['HTTP_X_REQUESTED_WITH'], 'XMLHttpRequest');
|
|
|
|
$this->assertEquals($client->getRequest()->getServer()['HTTP_X_REQUESTED_WITH'], 'XMLHttpRequest');
|
|
|
|
$this->assertFalse($client->getServerParameter('HTTP_X_REQUESTED_WITH', false));
|
|
|
|
$this->assertFalse($client->getServerParameter('HTTP_X_REQUESTED_WITH', false));
|
|
|
@ -115,7 +120,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetRequestWithIpAsHttpHost()
|
|
|
|
public function testGetRequestWithIpAsHttpHost()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'https://example.com/foo', [], [], ['HTTP_HOST' => '127.0.0.1']);
|
|
|
|
$client->request('GET', 'https://example.com/foo', [], [], ['HTTP_HOST' => '127.0.0.1']);
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('https://example.com/foo', $client->getRequest()->getUri());
|
|
|
|
$this->assertEquals('https://example.com/foo', $client->getRequest()->getUri());
|
|
|
@ -125,7 +130,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetResponse()
|
|
|
|
public function testGetResponse()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('foo'));
|
|
|
|
$client->setNextResponse(new Response('foo'));
|
|
|
|
$client->request('GET', 'http://example.com/');
|
|
|
|
$client->request('GET', 'http://example.com/');
|
|
|
|
|
|
|
|
|
|
|
@ -139,13 +144,13 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function testGetResponseNull()
|
|
|
|
public function testGetResponseNull()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$this->assertNull($client->getResponse());
|
|
|
|
$this->assertNull($client->getResponse());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetInternalResponse()
|
|
|
|
public function testGetInternalResponse()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new SpecialResponse('foo'));
|
|
|
|
$client->setNextResponse(new SpecialResponse('foo'));
|
|
|
|
$client->request('GET', 'http://example.com/');
|
|
|
|
$client->request('GET', 'http://example.com/');
|
|
|
|
|
|
|
|
|
|
|
@ -160,7 +165,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function testGetInternalResponseNull()
|
|
|
|
public function testGetInternalResponseNull()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$this->assertNull($client->getInternalResponse());
|
|
|
|
$this->assertNull($client->getInternalResponse());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -168,14 +173,14 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}';
|
|
|
|
$json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}';
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('POST', 'http://example.com/jsonrpc', [], [], [], $json);
|
|
|
|
$client->request('POST', 'http://example.com/jsonrpc', [], [], [], $json);
|
|
|
|
$this->assertEquals($json, $client->getRequest()->getContent());
|
|
|
|
$this->assertEquals($json, $client->getRequest()->getContent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetCrawler()
|
|
|
|
public function testGetCrawler()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('foo'));
|
|
|
|
$client->setNextResponse(new Response('foo'));
|
|
|
|
$crawler = $client->request('GET', 'http://example.com/');
|
|
|
|
$crawler = $client->request('GET', 'http://example.com/');
|
|
|
|
|
|
|
|
|
|
|
@ -188,18 +193,18 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function testGetCrawlerNull()
|
|
|
|
public function testGetCrawlerNull()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$this->assertNull($client->getCrawler());
|
|
|
|
$this->assertNull($client->getCrawler());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testRequestHttpHeaders()
|
|
|
|
public function testRequestHttpHeaders()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', '/');
|
|
|
|
$client->request('GET', '/');
|
|
|
|
$headers = $client->getRequest()->getServer();
|
|
|
|
$headers = $client->getRequest()->getServer();
|
|
|
|
$this->assertEquals('localhost', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header');
|
|
|
|
$this->assertEquals('localhost', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com');
|
|
|
|
$client->request('GET', 'http://www.example.com');
|
|
|
|
$headers = $client->getRequest()->getServer();
|
|
|
|
$headers = $client->getRequest()->getServer();
|
|
|
|
$this->assertEquals('www.example.com', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header');
|
|
|
|
$this->assertEquals('www.example.com', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header');
|
|
|
@ -208,7 +213,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
$headers = $client->getRequest()->getServer();
|
|
|
|
$headers = $client->getRequest()->getServer();
|
|
|
|
$this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header');
|
|
|
|
$this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com:8080');
|
|
|
|
$client->request('GET', 'http://www.example.com:8080');
|
|
|
|
$headers = $client->getRequest()->getServer();
|
|
|
|
$headers = $client->getRequest()->getServer();
|
|
|
|
$this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port');
|
|
|
|
$this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port');
|
|
|
@ -216,20 +221,20 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testRequestURIConversion()
|
|
|
|
public function testRequestURIConversion()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', '/foo');
|
|
|
|
$client->request('GET', '/foo');
|
|
|
|
$this->assertEquals('http://localhost/foo', $client->getRequest()->getUri(), '->request() converts the URI to an absolute one');
|
|
|
|
$this->assertEquals('http://localhost/foo', $client->getRequest()->getUri(), '->request() converts the URI to an absolute one');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com');
|
|
|
|
$client->request('GET', 'http://www.example.com');
|
|
|
|
$this->assertEquals('http://www.example.com', $client->getRequest()->getUri(), '->request() does not change absolute URIs');
|
|
|
|
$this->assertEquals('http://www.example.com', $client->getRequest()->getUri(), '->request() does not change absolute URIs');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/');
|
|
|
|
$client->request('GET', 'http://www.example.com/');
|
|
|
|
$client->request('GET', '/foo');
|
|
|
|
$client->request('GET', '/foo');
|
|
|
|
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/foo');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo');
|
|
|
|
$client->request('GET', '#');
|
|
|
|
$client->request('GET', '#');
|
|
|
|
$this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #');
|
|
|
|
$this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #');
|
|
|
@ -238,32 +243,32 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
$client->request('GET', '#foo');
|
|
|
|
$client->request('GET', '#foo');
|
|
|
|
$this->assertEquals('http://www.example.com/foo#foo', $client->getRequest()->getUri(), '->request() uses the previous request for #');
|
|
|
|
$this->assertEquals('http://www.example.com/foo#foo', $client->getRequest()->getUri(), '->request() uses the previous request for #');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/');
|
|
|
|
$client->request('GET', 'bar');
|
|
|
|
$client->request('GET', 'bar');
|
|
|
|
$this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
$this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'bar');
|
|
|
|
$client->request('GET', 'bar');
|
|
|
|
$this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
$this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/');
|
|
|
|
$client->request('GET', 'http');
|
|
|
|
$client->request('GET', 'http');
|
|
|
|
$this->assertEquals('http://www.example.com/foo/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
$this->assertEquals('http://www.example.com/foo/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/foo');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo');
|
|
|
|
$client->request('GET', 'http/bar');
|
|
|
|
$client->request('GET', 'http/bar');
|
|
|
|
$this->assertEquals('http://www.example.com/http/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
$this->assertEquals('http://www.example.com/http/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/');
|
|
|
|
$client->request('GET', 'http://www.example.com/');
|
|
|
|
$client->request('GET', 'http');
|
|
|
|
$client->request('GET', 'http');
|
|
|
|
$this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
$this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/foo');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo');
|
|
|
|
$client->request('GET', '?');
|
|
|
|
$client->request('GET', '?');
|
|
|
|
$this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?');
|
|
|
|
$this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?');
|
|
|
@ -275,7 +280,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testRequestReferer()
|
|
|
|
public function testRequestReferer()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'bar');
|
|
|
|
$client->request('GET', 'bar');
|
|
|
|
$server = $client->getRequest()->getServer();
|
|
|
|
$server = $client->getRequest()->getServer();
|
|
|
@ -284,7 +289,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testRequestHistory()
|
|
|
|
public function testRequestHistory()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'bar');
|
|
|
|
$client->request('GET', 'bar');
|
|
|
|
|
|
|
|
|
|
|
@ -294,7 +299,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testRequestCookies()
|
|
|
|
public function testRequestCookies()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, ['Set-Cookie' => 'foo=bar']));
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, ['Set-Cookie' => 'foo=bar']));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$this->assertEquals(['foo' => 'bar'], $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
|
|
|
|
$this->assertEquals(['foo' => 'bar'], $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
|
|
|
@ -305,7 +310,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testRequestSecureCookies()
|
|
|
|
public function testRequestSecureCookies()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, ['Set-Cookie' => 'foo=bar; path=/; secure']));
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, ['Set-Cookie' => 'foo=bar; path=/; secure']));
|
|
|
|
$client->request('GET', 'https://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'https://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
@ -314,7 +319,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testClick()
|
|
|
|
public function testClick()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>'));
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>'));
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
@ -325,7 +330,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testClickLink()
|
|
|
|
public function testClickLink()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>'));
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>'));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->clickLink('foo');
|
|
|
|
$client->clickLink('foo');
|
|
|
@ -335,7 +340,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testClickLinkNotFound()
|
|
|
|
public function testClickLinkNotFound()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foobar</a></html>'));
|
|
|
|
$client->setNextResponse(new Response('<html><a href="/foo">foobar</a></html>'));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
@ -349,7 +354,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testClickForm()
|
|
|
|
public function testClickForm()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
@ -360,7 +365,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testSubmit()
|
|
|
|
public function testSubmit()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
@ -371,7 +376,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testSubmitForm()
|
|
|
|
public function testSubmitForm()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><form name="signup" action="/foo"><input type="text" name="username" value="the username" /><input type="password" name="password" value="the password" /><input type="submit" value="Register" /></form></html>'));
|
|
|
|
$client->setNextResponse(new Response('<html><form name="signup" action="/foo"><input type="text" name="username" value="the username" /><input type="password" name="password" value="the password" /><input type="submit" value="Register" /></form></html>'));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
@ -391,7 +396,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testSubmitFormNotFound()
|
|
|
|
public function testSubmitFormNotFound()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
@ -408,7 +413,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testSubmitPreserveAuth()
|
|
|
|
public function testSubmitPreserveAuth()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient(['PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar']);
|
|
|
|
$client = $this->getBrowser(['PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar']);
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
@ -431,7 +436,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testSubmitPassthrewHeaders()
|
|
|
|
public function testSubmitPassthrewHeaders()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$headers = ['Accept-Language' => 'de'];
|
|
|
|
$headers = ['Accept-Language' => 'de'];
|
|
|
@ -445,7 +450,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testFollowRedirect()
|
|
|
|
public function testFollowRedirect()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
@ -462,19 +467,19 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
|
|
|
|
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true');
|
|
|
|
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('', 201, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->setNextResponse(new Response('', 201, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x');
|
|
|
|
$this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('', 201, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->setNextResponse(new Response('', 201, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
@ -489,12 +494,12 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testFollowRelativeRedirect()
|
|
|
|
public function testFollowRelativeRedirect()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => '/redirected']));
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => '/redirected']));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
|
|
|
|
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => '/redirected:1234']));
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => '/redirected:1234']));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$this->assertEquals('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls');
|
|
|
|
$this->assertEquals('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls');
|
|
|
@ -502,7 +507,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testFollowRedirectWithMaxRedirects()
|
|
|
|
public function testFollowRedirectWithMaxRedirects()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setMaxRedirects(1);
|
|
|
|
$client->setMaxRedirects(1);
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
@ -525,13 +530,13 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs');
|
|
|
|
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => '//www.example.org/']));
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => '//www.example.org/']));
|
|
|
|
$client->request('GET', 'https://www.example.com/');
|
|
|
|
$client->request('GET', 'https://www.example.com/');
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs');
|
|
|
|
$this->assertEquals('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs');
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->request('POST', 'http://www.example.com/foo/foobar', ['name' => 'bar']);
|
|
|
|
$client->request('POST', 'http://www.example.com/foo/foobar', ['name' => 'bar']);
|
|
|
|
|
|
|
|
|
|
|
@ -541,7 +546,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testFollowRedirectWithCookies()
|
|
|
|
public function testFollowRedirectWithCookies()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$client->setNextResponse(new Response('', 302, [
|
|
|
|
$client->setNextResponse(new Response('', 302, [
|
|
|
|
'Location' => 'http://www.example.com/redirected',
|
|
|
|
'Location' => 'http://www.example.com/redirected',
|
|
|
@ -562,7 +567,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
'HTTPS' => false,
|
|
|
|
'HTTPS' => false,
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$client->setNextResponse(new Response('', 302, [
|
|
|
|
$client->setNextResponse(new Response('', 302, [
|
|
|
|
'Location' => 'http://www.example.com/redirected',
|
|
|
|
'Location' => 'http://www.example.com/redirected',
|
|
|
@ -589,7 +594,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
'HTTP_REFERER' => 'http://www.example.com:8080/',
|
|
|
|
'HTTP_REFERER' => 'http://www.example.com:8080/',
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->setNextResponse(new Response('', 302, [
|
|
|
|
$client->setNextResponse(new Response('', 302, [
|
|
|
|
'Location' => 'http://www.example.com:8080/redirected',
|
|
|
|
'Location' => 'http://www.example.com:8080/redirected',
|
|
|
|
]));
|
|
|
|
]));
|
|
|
@ -600,7 +605,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testIsFollowingRedirects()
|
|
|
|
public function testIsFollowingRedirects()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$this->assertTrue($client->isFollowingRedirects(), '->getFollowRedirects() returns default value');
|
|
|
|
$this->assertTrue($client->isFollowingRedirects(), '->getFollowRedirects() returns default value');
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$client->followRedirects(false);
|
|
|
|
$this->assertFalse($client->isFollowingRedirects(), '->getFollowRedirects() returns assigned value');
|
|
|
|
$this->assertFalse($client->isFollowingRedirects(), '->getFollowRedirects() returns assigned value');
|
|
|
@ -608,7 +613,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetMaxRedirects()
|
|
|
|
public function testGetMaxRedirects()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$this->assertEquals(-1, $client->getMaxRedirects(), '->getMaxRedirects() returns default value');
|
|
|
|
$this->assertEquals(-1, $client->getMaxRedirects(), '->getMaxRedirects() returns default value');
|
|
|
|
$client->setMaxRedirects(3);
|
|
|
|
$client->setMaxRedirects(3);
|
|
|
|
$this->assertEquals(3, $client->getMaxRedirects(), '->getMaxRedirects() returns assigned value');
|
|
|
|
$this->assertEquals(3, $client->getMaxRedirects(), '->getMaxRedirects() returns assigned value');
|
|
|
@ -621,7 +626,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
$server = ['X_TEST_FOO' => 'bazbar'];
|
|
|
|
$server = ['X_TEST_FOO' => 'bazbar'];
|
|
|
|
$content = 'foobarbaz';
|
|
|
|
$content = 'foobarbaz';
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
$client->setNextResponse(new Response('', 307, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->setNextResponse(new Response('', 307, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content);
|
|
|
|
$client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content);
|
|
|
@ -641,7 +646,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
$server = ['X_TEST_FOO' => 'bazbar'];
|
|
|
|
$server = ['X_TEST_FOO' => 'bazbar'];
|
|
|
|
$content = 'foobarbaz';
|
|
|
|
$content = 'foobarbaz';
|
|
|
|
|
|
|
|
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
foreach ([301, 302, 303] as $code) {
|
|
|
|
foreach ([301, 302, 303] as $code) {
|
|
|
|
$client->setNextResponse(new Response('', $code, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->setNextResponse(new Response('', $code, ['Location' => 'http://www.example.com/redirected']));
|
|
|
@ -661,7 +666,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function testFollowMetaRefresh(string $content, string $expectedEndingUrl, bool $followMetaRefresh = true)
|
|
|
|
public function testFollowMetaRefresh(string $content, string $expectedEndingUrl, bool $followMetaRefresh = true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->followMetaRefresh($followMetaRefresh);
|
|
|
|
$client->followMetaRefresh($followMetaRefresh);
|
|
|
|
$client->setNextResponse(new Response($content));
|
|
|
|
$client->setNextResponse(new Response($content));
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
@ -691,7 +696,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testBack()
|
|
|
|
public function testBack()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
$parameters = ['foo' => 'bar'];
|
|
|
|
$parameters = ['foo' => 'bar'];
|
|
|
|
$files = ['myfile.foo' => 'baz'];
|
|
|
|
$files = ['myfile.foo' => 'baz'];
|
|
|
@ -711,7 +716,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testForward()
|
|
|
|
public function testForward()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
$parameters = ['foo' => 'bar'];
|
|
|
|
$parameters = ['foo' => 'bar'];
|
|
|
|
$files = ['myfile.foo' => 'baz'];
|
|
|
|
$files = ['myfile.foo' => 'baz'];
|
|
|
@ -732,7 +737,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testBackAndFrowardWithRedirects()
|
|
|
|
public function testBackAndFrowardWithRedirects()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
$client->request('GET', 'http://www.example.com/foo');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo');
|
|
|
|
$client->setNextResponse(new Response('', 301, ['Location' => 'http://www.example.com/redirected']));
|
|
|
|
$client->setNextResponse(new Response('', 301, ['Location' => 'http://www.example.com/redirected']));
|
|
|
@ -751,7 +756,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testReload()
|
|
|
|
public function testReload()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
$parameters = ['foo' => 'bar'];
|
|
|
|
$parameters = ['foo' => 'bar'];
|
|
|
|
$files = ['myfile.foo' => 'baz'];
|
|
|
|
$files = ['myfile.foo' => 'baz'];
|
|
|
@ -770,7 +775,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testRestart()
|
|
|
|
public function testRestart()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->restart();
|
|
|
|
$client->restart();
|
|
|
|
|
|
|
|
|
|
|
@ -780,7 +785,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testInsulatedRequests()
|
|
|
|
public function testInsulatedRequests()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$client->insulate();
|
|
|
|
$client->insulate();
|
|
|
|
$client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar')");
|
|
|
|
$client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar')");
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
|
$client->request('GET', 'http://www.example.com/foo/foobar');
|
|
|
@ -799,7 +804,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetServerParameter()
|
|
|
|
public function testGetServerParameter()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
|
|
|
|
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
|
|
|
|
$this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
|
|
|
$this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
|
|
|
$this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue'));
|
|
|
|
$this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue'));
|
|
|
@ -807,7 +812,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testSetServerParameter()
|
|
|
|
public function testSetServerParameter()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
|
|
|
|
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
|
|
|
|
$this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
|
|
|
$this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
|
|
@ -821,7 +826,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testSetServerParameterInRequest()
|
|
|
|
public function testSetServerParameterInRequest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
|
|
|
|
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
|
|
|
|
$this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
|
|
|
$this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
|
|
|
@ -855,7 +860,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testRequestWithRelativeUri()
|
|
|
|
public function testRequestWithRelativeUri()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
$client->request('GET', '/', [], [], [
|
|
|
|
$client->request('GET', '/', [], [], [
|
|
|
|
'HTTP_HOST' => 'testhost',
|
|
|
|
'HTTP_HOST' => 'testhost',
|
|
|
@ -872,7 +877,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testInternalRequest()
|
|
|
|
public function testInternalRequest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
|
|
|
|
|
|
|
|
$client->request('GET', 'https://www.example.com/https/www.example.com', [], [], [
|
|
|
|
$client->request('GET', 'https://www.example.com/https/www.example.com', [], [], [
|
|
|
|
'HTTP_HOST' => 'testhost',
|
|
|
|
'HTTP_HOST' => 'testhost',
|
|
|
@ -890,7 +895,7 @@ class AbstractBrowserTest extends TestCase
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function testInternalRequestNull()
|
|
|
|
public function testInternalRequestNull()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$client = new TestClient();
|
|
|
|
$client = $this->getBrowser();
|
|
|
|
$this->assertNull($client->getInternalRequest());
|
|
|
|
$this->assertNull($client->getInternalRequest());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|