From 6d3ec633cd8db3b49864a078282fc0d1c8946505 Mon Sep 17 00:00:00 2001 From: Hassan Amouhzi Date: Sat, 30 May 2015 00:07:08 +0200 Subject: [PATCH] [BrowserKit] Fix bug when uri starts with http. | Q | A | ------------- | --- | Fixed tickets | | License | MIT --- src/Symfony/Component/BrowserKit/Client.php | 2 +- .../Component/BrowserKit/Tests/ClientTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 7f640a7919..06add6c34a 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -556,7 +556,7 @@ abstract class Client protected function getAbsoluteUri($uri) { // already absolute? - if (0 === strpos($uri, 'http')) { + if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) { return $uri; } diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index a6e5ba9e9a..3a8de92096 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -207,6 +207,21 @@ class ClientTest extends \PHPUnit_Framework_TestCase $client->request('GET', 'http://www.example.com/foo/foobar'); $client->request('GET', 'bar'); $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo/'); + $client->request('GET', 'http'); + $this->assertEquals('http://www.example.com/foo/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo'); + $client->request('GET', 'http/bar'); + $this->assertEquals('http://www.example.com/http/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/'); + $client->request('GET', 'http'); + $this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); } public function testRequestURIConversionByServerHost()