From dfe30d91844677c2c41f2bbc63f933c116dbe52a Mon Sep 17 00:00:00 2001 From: mattab <matthieu.aubry@gmail.com> Date: Tue, 2 Dec 2014 21:33:58 +1300 Subject: [PATCH] Fix unit tests as parse_url does not work when there is no scheme on 5.3 till 5.4.7 refs #6652 --- tests/PHPUnit/Unit/UrlHelperTest.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/PHPUnit/Unit/UrlHelperTest.php b/tests/PHPUnit/Unit/UrlHelperTest.php index dc4a97047b..7684f62965 100644 --- a/tests/PHPUnit/Unit/UrlHelperTest.php +++ b/tests/PHPUnit/Unit/UrlHelperTest.php @@ -8,6 +8,7 @@ namespace Piwik\Tests\Unit; +use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\UrlHelper; use Spyc; @@ -204,11 +205,22 @@ class Core_UrlHelperTest extends \PHPUnit_Framework_TestCase $this->assertEquals('', UrlHelper::getHostFromUrl(null)); $this->assertEquals('localhost', UrlHelper::getHostFromUrl('http://localhost')); $this->assertEquals('localhost', UrlHelper::getHostFromUrl('http://localhost/path')); - $this->assertEquals('localhost', UrlHelper::getHostFromUrl('//localhost/path')); - $this->assertEquals('localhost', UrlHelper::getHostFromUrl('//localhost/path?test=test2')); $this->assertEquals('localhost', UrlHelper::getHostFromUrl('localhost/path')); $this->assertEquals('sub.localhost', UrlHelper::getHostFromUrl('sub.localhost/path')); $this->assertEquals('sub.localhost', UrlHelper::getHostFromUrl('http://sub.localhost/path/?query=test')); + + if(SystemTestCase::isPhpVersion53()) { + //parse_url was fixed in 5,4,7 + // Fixed host recognition when scheme is omitted and a leading component separator is present. + // http://php.net/parse_url + return; + } + + $this->assertEquals('localhost', UrlHelper::getHostFromUrl('//localhost/path')); + $this->assertEquals('localhost', UrlHelper::getHostFromUrl('//localhost/path?test=test2')); + $this->assertEquals('example.org', UrlHelper::getHostFromUrl('//example.org/path')); + $this->assertEquals('example.org', UrlHelper::getHostFromUrl('//example.org/path?test=test2')); + } /** -- GitLab