public function ClientTest::testFollowRedirectWithMaxRedirects in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/browser-kit/Tests/ClientTest.php \Symfony\Component\BrowserKit\Tests\ClientTest::testFollowRedirectWithMaxRedirects()
File
- vendor/
symfony/ browser-kit/ Tests/ ClientTest.php, line 397
Class
Namespace
Symfony\Component\BrowserKit\TestsCode
public function testFollowRedirectWithMaxRedirects() {
$client = new TestClient();
$client
->setMaxRedirects(1);
$client
->setNextResponse(new Response('', 302, array(
'Location' => 'http://www.example.com/redirected',
)));
$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');
$client
->setNextResponse(new Response('', 302, array(
'Location' => 'http://www.example.com/redirected2',
)));
try {
$client
->followRedirect();
$this
->fail('->followRedirect() throws a \\LogicException if the request was redirected and limit of redirections was reached');
} catch (\Exception $e) {
$this
->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \\LogicException if the request was redirected and limit of redirections was reached');
}
$client
->setNextResponse(new Response('', 302, array(
'Location' => 'http://www.example.com/redirected',
)));
$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');
$client
->setNextResponse(new Response('', 302, array(
'Location' => '/redirected',
)));
$client
->request('GET', 'http://www.example.com/foo/foobar');
$this
->assertEquals('http://www.example.com/redirected', $client
->getRequest()
->getUri(), '->followRedirect() follows relative URLs');
$client = new TestClient();
$client
->setNextResponse(new Response('', 302, array(
'Location' => '//www.example.org/',
)));
$client
->request('GET', 'https://www.example.com/');
$this
->assertEquals('https://www.example.org/', $client
->getRequest()
->getUri(), '->followRedirect() follows protocol-relative URLs');
$client = new TestClient();
$client
->setNextResponse(new Response('', 302, array(
'Location' => 'http://www.example.com/redirected',
)));
$client
->request('POST', 'http://www.example.com/foo/foobar', array(
'name' => 'bar',
));
$this
->assertEquals('get', $client
->getRequest()
->getMethod(), '->followRedirect() uses a get for 302');
$this
->assertEquals(array(), $client
->getRequest()
->getParameters(), '->followRedirect() does not submit parameters when changing the method');
}