bug #11516 [BrowserKit] Fix browser kit redirect with ports (dakota)

This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #11516).

Discussion
----------

[BrowserKit] Fix browser kit redirect with ports

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | No ticket opened
| License       | MIT
| Doc PR        | None

Whilst using Mink to do automated tests, I encountered a problem where redirects with ports would not work as the port was removed in the `updateServerFromURI()` method. This PR fixes the problem.

During my testing I encountered `$client->followRedirects(false);` in the ClientTest class that was causing the redirectWithPort test to pass even though it should have been failing (Removing the line caused the test to correctly fail before the patch was written)

Commits
-------

39973de [BrowserKit] Fix browser kit redirect with ports
This commit is contained in:
Fabien Potencier 2014-08-05 09:17:23 +02:00
commit 6094b5b3a9
2 changed files with 3 additions and 3 deletions

View File

@ -607,7 +607,7 @@ abstract class Client
private function updateServerFromUri($server, $uri)
{
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
$server['HTTP_HOST'] = $this->extractHost($uri);
$scheme = parse_url($uri, PHP_URL_SCHEME);
$server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme;
unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']);

View File

@ -484,11 +484,11 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$headers = array(
'HTTP_HOST' => 'www.example.com:8080',
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
'HTTPS' => false
'HTTPS' => false,
'HTTP_REFERER' => 'http://www.example.com:8080/'
);
$client = new TestClient();
$client->followRedirects(false);
$client->setNextResponse(new Response('', 302, array(
'Location' => 'http://www.example.com:8080/redirected',
)));