From ce7b0b6480aa854ee6893f5c889277b0e3b13efc Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 6 Apr 2016 22:00:52 +0200 Subject: Fixes #531 - Title retrieving is failing with multiple use case see https://github.com/shaarli/Shaarli/issues/531 for details --- tests/HttpUtils/GetHttpUrlTest.php | 27 +++++++++++++++++++++++++++ tests/Url/UrlTest.php | 15 +++++++++++++++ 2 files changed, 42 insertions(+) (limited to 'tests') diff --git a/tests/HttpUtils/GetHttpUrlTest.php b/tests/HttpUtils/GetHttpUrlTest.php index fd293505..ea53de5f 100644 --- a/tests/HttpUtils/GetHttpUrlTest.php +++ b/tests/HttpUtils/GetHttpUrlTest.php @@ -35,4 +35,31 @@ class GetHttpUrlTest extends PHPUnit_Framework_TestCase $this->assertFalse($headers); $this->assertFalse($content); } + + /** + * Test getAbsoluteUrl with relative target URL. + */ + public function testGetAbsoluteUrlWithRelative() + { + $origin = 'http://non.existent/blabla/?test'; + $target = '/stuff.php'; + + $expected = 'http://non.existent/stuff.php'; + $this->assertEquals($expected, getAbsoluteUrl($origin, $target)); + + $target = 'stuff.php'; + $expected = 'http://non.existent/blabla/stuff.php'; + $this->assertEquals($expected, getAbsoluteUrl($origin, $target)); + } + + /** + * Test getAbsoluteUrl with absolute target URL. + */ + public function testGetAbsoluteUrlWithAbsolute() + { + $origin = 'http://non.existent/blabla/?test'; + $target = 'http://other.url/stuff.php'; + + $this->assertEquals($target, getAbsoluteUrl($origin, $target)); + } } diff --git a/tests/Url/UrlTest.php b/tests/Url/UrlTest.php index a64a73ea..5fdc8617 100644 --- a/tests/Url/UrlTest.php +++ b/tests/Url/UrlTest.php @@ -181,4 +181,19 @@ class UrlTest extends PHPUnit_Framework_TestCase $url = new Url('ftp://save.tld/mysave'); $this->assertFalse($url->isHttp()); } + + /** + * Test IndToAscii. + */ + function testIndToAscii() + { + $ind = 'http://www.académie-française.fr/'; + $expected = 'http://www.xn--acadmie-franaise-npb1a.fr/'; + $url = new Url($ind); + $this->assertEquals($expected, $url->indToAscii()); + + $notInd = 'http://www.academie-francaise.fr/'; + $url = new Url($notInd); + $this->assertEquals($notInd, $url->indToAscii()); + } } -- cgit v1.2.3