$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();