From 482d67bd523bf12f36508a0131d09fe299ee02f4 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sun, 6 Sep 2015 21:31:37 +0200 Subject: 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 --- tests/HttpUtils/GetHttpUrlTest.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/HttpUtils/GetHttpUrlTest.php (limited to 'tests/HttpUtils/GetHttpUrlTest.php') 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 @@ +assertEquals('HTTP Error', $headers[0]); + $this->assertRegexp( + '/failed to open stream: No such file or directory/', + $content + ); + } + + /** + * Get an invalid remote URL + */ + public function testGetInvalidRemoteUrl() + { + list($headers, $content) = get_http_url('http://non.existent', 1); + $this->assertEquals('HTTP Error', $headers[0]); + $this->assertRegexp( + '/Name or service not known/', + $content + ); + } +} -- cgit v1.2.3