diff options
Diffstat (limited to 'tests/HttpUtils/GetHttpUrlTest.php')
-rw-r--r-- | tests/HttpUtils/GetHttpUrlTest.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/HttpUtils/GetHttpUrlTest.php b/tests/HttpUtils/GetHttpUrlTest.php new file mode 100644 index 00000000..76092b80 --- /dev/null +++ b/tests/HttpUtils/GetHttpUrlTest.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 | } | ||