diff options
author | VirtualTam <virtualtam@flibidi.net> | 2015-09-06 20:32:01 +0200 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2015-09-06 20:32:01 +0200 |
commit | 0a813cfd7cdf3c81faba8568bf6e2e667aae6f13 (patch) | |
tree | fddc1a6d7a92728d0dfdcbb676f113a09325b1c2 /tests | |
parent | f5d6b19b73cd026cb1d937aab16d48b43e412c77 (diff) | |
parent | 451314eb48c7d922264adc6eada8a0273b12344c (diff) | |
download | Shaarli-0a813cfd7cdf3c81faba8568bf6e2e667aae6f13.tar.gz Shaarli-0a813cfd7cdf3c81faba8568bf6e2e667aae6f13.tar.zst Shaarli-0a813cfd7cdf3c81faba8568bf6e2e667aae6f13.zip |
Merge pull request #334 from virtualtam/refactor/http-utils
HTTP: move utils to a proper file, add tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/HttpUtilsTest.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/HttpUtilsTest.php b/tests/HttpUtilsTest.php new file mode 100644 index 00000000..76092b80 --- /dev/null +++ b/tests/HttpUtilsTest.php | |||
@@ -0,0 +1,38 @@ | |||
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 | } | ||