X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FHttpUtils%2FGetHttpUrlTest.php;h=ea53de5f27feabec829489c442c728bf5b661cf4;hb=fb1b182fbf0ee5afed586f77eec84d7a906831ef;hp=fd29350534e6675dd7469526607b6dbbe495f34d;hpb=893338f0d407a0989454d5e3c0e43c97f7eface5;p=github%2Fshaarli%2FShaarli.git 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)); + } }