diff options
author | VirtualTam <virtualtam@flibidi.net> | 2018-12-03 00:34:53 +0100 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2019-01-12 22:47:48 +0100 |
commit | 51753e403fa69c0ce124ede27d300477e3e799ca (patch) | |
tree | 0afe2a84598648b49cc53bb3e8640569ac370240 /tests/HttpUtils/GetHttpUrlTest.php | |
parent | fb1b182fbf0ee5afed586f77eec84d7a906831ef (diff) | |
download | Shaarli-51753e403fa69c0ce124ede27d300477e3e799ca.tar.gz Shaarli-51753e403fa69c0ce124ede27d300477e3e799ca.tar.zst Shaarli-51753e403fa69c0ce124ede27d300477e3e799ca.zip |
namespacing: move HTTP utilities along \Shaarli\Http\ classes
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'tests/HttpUtils/GetHttpUrlTest.php')
-rw-r--r-- | tests/HttpUtils/GetHttpUrlTest.php | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/tests/HttpUtils/GetHttpUrlTest.php b/tests/HttpUtils/GetHttpUrlTest.php deleted file mode 100644 index ea53de5f..00000000 --- a/tests/HttpUtils/GetHttpUrlTest.php +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | <?php | ||
2 | /** | ||
3 | * HttpUtils' tests | ||
4 | */ | ||
5 | |||
6 | require_once 'application/HttpUtils.php'; | ||
7 | |||
8 | /** | ||
9 | * Unitary tests for get_http_response() | ||
10 | */ | ||
11 | class GetHttpUrlTest extends PHPUnit_Framework_TestCase | ||
12 | { | ||
13 | /** | ||
14 | * Get an invalid local URL | ||
15 | */ | ||
16 | public function testGetInvalidLocalUrl() | ||
17 | { | ||
18 | // Local | ||
19 | list($headers, $content) = get_http_response('/non/existent', 1); | ||
20 | $this->assertEquals('Invalid HTTP Url', $headers[0]); | ||
21 | $this->assertFalse($content); | ||
22 | |||
23 | // Non HTTP | ||
24 | list($headers, $content) = get_http_response('ftp://save.tld/mysave', 1); | ||
25 | $this->assertEquals('Invalid HTTP Url', $headers[0]); | ||
26 | $this->assertFalse($content); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * Get an invalid remote URL | ||
31 | */ | ||
32 | public function testGetInvalidRemoteUrl() | ||
33 | { | ||
34 | list($headers, $content) = @get_http_response('http://non.existent', 1); | ||
35 | $this->assertFalse($headers); | ||
36 | $this->assertFalse($content); | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * Test getAbsoluteUrl with relative target URL. | ||
41 | */ | ||
42 | public function testGetAbsoluteUrlWithRelative() | ||
43 | { | ||
44 | $origin = 'http://non.existent/blabla/?test'; | ||
45 | $target = '/stuff.php'; | ||
46 | |||
47 | $expected = 'http://non.existent/stuff.php'; | ||
48 | $this->assertEquals($expected, getAbsoluteUrl($origin, $target)); | ||
49 | |||
50 | $target = 'stuff.php'; | ||
51 | $expected = 'http://non.existent/blabla/stuff.php'; | ||
52 | $this->assertEquals($expected, getAbsoluteUrl($origin, $target)); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * Test getAbsoluteUrl with absolute target URL. | ||
57 | */ | ||
58 | public function testGetAbsoluteUrlWithAbsolute() | ||
59 | { | ||
60 | $origin = 'http://non.existent/blabla/?test'; | ||
61 | $target = 'http://other.url/stuff.php'; | ||
62 | |||
63 | $this->assertEquals($target, getAbsoluteUrl($origin, $target)); | ||
64 | } | ||
65 | } | ||