diff --git a/tests/PHPUnit/Unit/UrlHelperTest.php b/tests/PHPUnit/Unit/UrlHelperTest.php index dc4a97047b71442b59414bd6e7cd3b0359551426..7684f6296580959e79afaeddf37a6259175e3b76 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')); + } /**