]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/http/HttpUtils/GetHttpUrlTest.php
6 namespace Shaarli\Http
;
8 require_once 'application/http/HttpUtils.php';
11 * Unitary tests for get_http_response()
13 class GetHttpUrlTest
extends \Shaarli\TestCase
16 * Get an invalid local URL
18 public function testGetInvalidLocalUrl()
21 list($headers, $content) = get_http_response('/non/existent', 1);
22 $this->assertEquals('Invalid HTTP UrlUtils', $headers[0]);
23 $this->assertFalse($content);
26 list($headers, $content) = get_http_response('ftp://save.tld/mysave', 1);
27 $this->assertEquals('Invalid HTTP UrlUtils', $headers[0]);
28 $this->assertFalse($content);
32 * Get an invalid remote URL
34 public function testGetInvalidRemoteUrl()
36 list($headers, $content) = @get_http_response('http://non.existent', 1);
37 $this->assertFalse($headers);
38 $this->assertFalse($content);
42 * Test getAbsoluteUrl with relative target URL.
44 public function testGetAbsoluteUrlWithRelative()
46 $origin = 'http://non.existent/blabla/?test';
47 $target = '/stuff.php';
49 $expected = 'http://non.existent/stuff.php';
50 $this->assertEquals($expected, getAbsoluteUrl($origin, $target));
52 $target = 'stuff.php';
53 $expected = 'http://non.existent/blabla/stuff.php';
54 $this->assertEquals($expected, getAbsoluteUrl($origin, $target));
58 * Test getAbsoluteUrl with absolute target URL.
60 public function testGetAbsoluteUrlWithAbsolute()
62 $origin = 'http://non.existent/blabla/?test';
63 $target = 'http://other.url/stuff.php';
65 $this->assertEquals($target, getAbsoluteUrl($origin, $target));