diff options
author | VirtualTam <virtualtam@flibidi.net> | 2015-09-06 21:31:37 +0200 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2015-09-14 20:27:16 +0200 |
commit | 482d67bd523bf12f36508a0131d09fe299ee02f4 (patch) | |
tree | b4e7c6ddaa1d88cc49bc96c2524f12431d8fcce0 /tests/HttpUtilsTest.php | |
parent | 7b114771d337af3bfd51d8fda1e8f2fd5b39535d (diff) | |
download | Shaarli-482d67bd523bf12f36508a0131d09fe299ee02f4.tar.gz Shaarli-482d67bd523bf12f36508a0131d09fe299ee02f4.tar.zst Shaarli-482d67bd523bf12f36508a0131d09fe299ee02f4.zip |
HTTP: move server URL functions to `HttpUtils.php`
Relates to #333
Modifications:
- refactor server URL utility functions
- do not access global `$_SERVER` variables
- add test coverage
- improve readability
- apply coding conventions
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'tests/HttpUtilsTest.php')
-rw-r--r-- | tests/HttpUtilsTest.php | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/tests/HttpUtilsTest.php b/tests/HttpUtilsTest.php deleted file mode 100644 index 76092b80..00000000 --- a/tests/HttpUtilsTest.php +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | <?php | ||
2 | /** | ||
3 | * HttpUtils' tests | ||
4 | */ | ||
5 | |||
6 | require_once 'application/HttpUtils.php'; | ||
7 | |||
8 | /** | ||
9 | * Unitary tests for get_http_url() | ||
10 | */ | ||
11 | class GetHttpUrlTest extends PHPUnit_Framework_TestCase | ||
12 | { | ||
13 | /** | ||
14 | * Get an invalid local URL | ||
15 | */ | ||
16 | public function testGetInvalidLocalUrl() | ||
17 | { | ||
18 | list($headers, $content) = get_http_url('/non/existent', 1); | ||
19 | $this->assertEquals('HTTP Error', $headers[0]); | ||
20 | $this->assertRegexp( | ||
21 | '/failed to open stream: No such file or directory/', | ||
22 | $content | ||
23 | ); | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * Get an invalid remote URL | ||
28 | */ | ||
29 | public function testGetInvalidRemoteUrl() | ||
30 | { | ||
31 | list($headers, $content) = get_http_url('http://non.existent', 1); | ||
32 | $this->assertEquals('HTTP Error', $headers[0]); | ||
33 | $this->assertRegexp( | ||
34 | '/Name or service not known/', | ||
35 | $content | ||
36 | ); | ||
37 | } | ||
38 | } | ||