Skip to content

Commit 2ace5d8

Browse files
zombergnicolas-grekas
authored andcommitted
[BrowserKit] Added test for followRedirect method (POST method)
1 parent 37cd583 commit 2ace5d8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,26 @@ public function testFollowRedirectWithPort()
473473
$this->assertEquals($headers, $client->getRequest()->getServer());
474474
}
475475

476+
public function testFollowRedirectWithPostMethod()
477+
{
478+
$parameters = array('foo' => 'bar');
479+
$files = array('myfile.foo' => 'baz');
480+
$server = array('X_TEST_FOO' => 'bazbar');
481+
$content = 'foobarbaz';
482+
483+
$client = new TestClient();
484+
485+
$client->setNextResponse(new Response('', 307, array('Location' => 'http://www.example.com/redirected')));
486+
$client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content);
487+
488+
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method');
489+
$this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->followRedirect() keeps parameters with POST method');
490+
$this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->followRedirect() keeps files with POST method');
491+
$this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->followRedirect() keeps $_SERVER with POST method');
492+
$this->assertEquals($content, $client->getRequest()->getContent(), '->followRedirect() keeps content with POST method');
493+
$this->assertEquals('POST', $client->getRequest()->getMethod(), '->followRedirect() keeps request method');
494+
}
495+
476496
public function testBack()
477497
{
478498
$client = new TestClient();

0 commit comments

Comments
 (0)