diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/it_url.t | 31 | ||||
-rw-r--r-- | tests/it_url.testserver.php | 11 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/it_url.t b/tests/it_url.t index 0655bda..e5f5c6b 100755 --- a/tests/it_url.t +++ b/tests/it_url.t @@ -164,6 +164,37 @@ $output = server_output(); if (!$res) diag($output); +$res = is( + it_url::get('http://localhost:8000/relative_redirect'), + "Testserver output after relative redirect", + 'TODO: it_url::get() follows relative redirect correctly', +); +$output = server_output(); +if (!$res) + diag($output); + +$res = is( + it_url::get('http://localhost:8000/nohost_redirect'), + "Testserver output after nohost redirect", + 'TODO: it_url::get() follows redirect without host correctly', +); +$output = server_output(); +if (!$res) + diag($output); + + +$res = ok( + !it_url::get('url' => 'http://localhost:8000/does_not_exist', 'retries' => 4), + 'it_url::get() retries on empty response', +); +$output = server_output(); +$res2 = ok( + count(preg_grep('/^Got Request:/', $output)) == 5, + 'it_url::get() respects set retry count', +); +if (!$res || !$res2) + diag($output); + $res = ok( !it_url::get(U('http://localhost:8000/redirect_loop', 'num' => 10)), 'it_url::get() handles redirect loop', diff --git a/tests/it_url.testserver.php b/tests/it_url.testserver.php index 12ce892..2d10052 100644 --- a/tests/it_url.testserver.php +++ b/tests/it_url.testserver.php @@ -22,7 +22,18 @@ switch ($_SERVER['PHP_SELF']) it_url::redirect(U("redirect_loop", array('num' => $_REQUEST['num'] - 1))); break; + case "/nohost_redirect": + header('Location: /redirect_target?type=nohost', true, 301); + exit; + + case "/relative_redirect": + header('Location: ../redirect_target?type=relative', true, 301); + exit; + case "/redirect_target": echo 'Testserver output after ' . $_REQUEST['type'] . ' redirect'; break; + + default: + fwrite($stderr, "Unknown path '$_SERVER[PHP_SELF]' not handled!\n"); } |