Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c4069a4

Browse filesBrowse files
minor #19392 [BrowserKit] Added test for followRedirect method (POST method) (zomberg)
This PR was squashed before being merged into the 2.7 branch (closes #19392). Discussion ---------- [BrowserKit] Added test for followRedirect method (POST method) | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Test covers 'else' branches in these conditions: ```php if (in_array($this->internalResponse->getStatus(), array(302, 303))) { $method = 'get'; $files = array(); $content = null; } else { $method = $request->getMethod(); $files = $request->getFiles(); $content = $request->getContent(); } if ('get' === strtolower($method)) { // Don't forward parameters for GET request as it should reach the redirection URI $parameters = array(); } else { $parameters = $request->getParameters(); } ``` Commits ------- 2ace5d8 [BrowserKit] Added test for followRedirect method (POST method)
2 parents f6a77a1 + 2ace5d8 commit c4069a4
Copy full SHA for c4069a4

File tree

1 file changed

+20
-0
lines changed
Filter options

1 file changed

+20
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Tests/ClientTest.php
+20Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.