summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/it_url.t26
-rw-r--r--test/it_url.testserver.php5
2 files changed, 28 insertions, 3 deletions
diff --git a/test/it_url.t b/test/it_url.t
index 02fe45c..01de74b 100755
--- a/test/it_url.t
+++ b/test/it_url.t
@@ -1,7 +1,7 @@
#!/www/server/bin/php -qC
<?php
-# Tests for url.class, currently only constructor's parser
+require 'it_url_server.php';
it::getopt("Usage: it_url.t [OPTIONS]");
@@ -131,8 +131,6 @@ is(
);
$_SERVER['PHP_SELF'] = $php_self;
-require 'it_url_server.php';
-
is(it_url::is_reachable('http://www.gna.ch/'), true, "is_reachable('http://www.gna.ch/')");
is(it_url::is_reachable('http://www.search.ch/not_found'), false, "is_reachable('http://www.search.ch/not_found')");
is(it_url::is_reachable('http://bogus.url'), false, "is_reachable('http://bogus.url')");
@@ -259,6 +257,28 @@ if (!ok(
$output = handle_server(
ok(
+ it_url::get(['url' => "http://$host/not_found_with_body", 'empty_on_fail' => false, 'it_error' => false]),
+ 'it_url::get() on 404 with body'
+ )
+);
+
+$output = handle_server(
+ ok(
+ !it_url::get(['url' => "http://$host/not_found_with_body", 'empty_on_fail' => true, 'it_error' => false]),
+ 'it_url::get() on 404 with body and empty_on_fail'
+ )
+);
+
+$output = handle_server(
+ is(
+ it::filter_keys(it_url::get(['url' => "http://$host/not_found_with_body", 'empty_on_fail' => true, 'it_error' => false, 'assoc' => true]), 'status,data'),
+ [],
+ 'it_url::get() on 404 with body, empty_on_fail and assoc'
+ )
+);
+
+$output = handle_server(
+ ok(
!it_url::get(['url' => "http://$host/repeat?num=0", 'retries' => 4]),
'it_url::get() on empty page'
)
diff --git a/test/it_url.testserver.php b/test/it_url.testserver.php
index 978e4af..ca5300c 100644
--- a/test/it_url.testserver.php
+++ b/test/it_url.testserver.php
@@ -80,6 +80,11 @@ switch ($_SERVER['PHP_SELF'])
echo $iserror ? "failure" : "success";
break;
+ case "/not_found_with_body":
+ http_response_code(404);
+ echo 'Testserver 404 output';
+ break;
+
default:
http_response_code(404);
fwrite($stderr, "Unknown path '$_SERVER[PHP_SELF]' not handled!\n");