X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fbrowser-kit%2FTests%2FClientTest.php;h=bbaceb0c329627bb4265bd24acbf9209da993373;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=9e1530168e20b2ca15addd7db730a6524a63c548;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/browser-kit/Tests/ClientTest.php b/vendor/symfony/browser-kit/Tests/ClientTest.php index 9e1530168..bbaceb0c3 100644 --- a/vendor/symfony/browser-kit/Tests/ClientTest.php +++ b/vendor/symfony/browser-kit/Tests/ClientTest.php @@ -13,8 +13,8 @@ namespace Symfony\Component\BrowserKit\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Client; -use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\CookieJar; +use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\Response; class SpecialResponse extends Response @@ -510,6 +510,28 @@ class ClientTest extends TestCase $this->assertEquals('POST', $client->getRequest()->getMethod(), '->followRedirect() keeps request method'); } + public function testFollowRedirectDropPostMethod() + { + $parameters = array('foo' => 'bar'); + $files = array('myfile.foo' => 'baz'); + $server = array('X_TEST_FOO' => 'bazbar'); + $content = 'foobarbaz'; + + $client = new TestClient(); + + foreach (array(301, 302, 303) as $code) { + $client->setNextResponse(new Response('', $code, array('Location' => 'http://www.example.com/redirected'))); + $client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); + + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method on response code: '.$code.'.'); + $this->assertEmpty($client->getRequest()->getParameters(), '->followRedirect() drops parameters with POST method on response code: '.$code.'.'); + $this->assertEmpty($client->getRequest()->getFiles(), '->followRedirect() drops files with POST method on response code: '.$code.'.'); + $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->followRedirect() keeps $_SERVER with POST method on response code: '.$code.'.'); + $this->assertEmpty($client->getRequest()->getContent(), '->followRedirect() drops content with POST method on response code: '.$code.'.'); + $this->assertEquals('GET', $client->getRequest()->getMethod(), '->followRedirect() drops request method to GET on response code: '.$code.'.'); + } + } + public function testBack() { $client = new TestClient(); @@ -551,6 +573,25 @@ class ClientTest extends TestCase $this->assertEquals($content, $client->getRequest()->getContent(), '->forward() keeps content'); } + public function testBackAndFrowardWithRedirects() + { + $client = new TestClient(); + + $client->request('GET', 'http://www.example.com/foo'); + $client->setNextResponse(new Response('', 301, array('Location' => 'http://www.example.com/redirected'))); + $client->request('GET', 'http://www.example.com/bar'); + + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), 'client followed redirect'); + + $client->back(); + + $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->back() goes back in the history skipping redirects'); + + $client->forward(); + + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->forward() goes forward in the history skipping redirects'); + } + public function testReload() { $client = new TestClient();