aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-09-06 20:32:01 +0200
committerVirtualTam <virtualtam@flibidi.net>2015-09-06 20:32:01 +0200
commit0a813cfd7cdf3c81faba8568bf6e2e667aae6f13 (patch)
treefddc1a6d7a92728d0dfdcbb676f113a09325b1c2 /tests
parentf5d6b19b73cd026cb1d937aab16d48b43e412c77 (diff)
parent451314eb48c7d922264adc6eada8a0273b12344c (diff)
downloadShaarli-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.php38
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
6require_once 'application/HttpUtils.php';
7
8/**
9 * Unitary tests for get_http_url()
10 */
11class 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}