diff options
author | Nathan Gass | 2012-03-22 18:18:42 +0000 |
---|---|---|
committer | Nathan Gass | 2012-03-22 18:18:42 +0000 |
commit | d59a4921188753dbe4c0161081755a28112c3ef6 (patch) | |
tree | 81496414d988f37f1db9d92c9750d888ffa13746 /devel-utf8/tests/it_url.t | |
parent | ca11771e8fad5fef96615df4c44e04b8fb60ac31 (diff) | |
download | itools-d59a4921188753dbe4c0161081755a28112c3ef6.tar.gz itools-d59a4921188753dbe4c0161081755a28112c3ef6.tar.bz2 itools-d59a4921188753dbe4c0161081755a28112c3ef6.zip |
Branch itools/devel-utf8 created
Diffstat (limited to 'devel-utf8/tests/it_url.t')
-rwxr-xr-x | devel-utf8/tests/it_url.t | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/devel-utf8/tests/it_url.t b/devel-utf8/tests/it_url.t new file mode 100755 index 0000000..e8507aa --- /dev/null +++ b/devel-utf8/tests/it_url.t @@ -0,0 +1,135 @@ +#!/www/server/bin/php -qC +<?php + +# Tests for url.class, currently only constructor's parser + +# Create object and parse url +$url = new it_url('HTTP://falcon:joshua@www.Relog.CH:80/default.asp'); + +is( + $url->url, + 'http://www.relog.ch/', + '$url->url' +); + +is( + $url->protocol, + 'http', + '$url->protocol' +); + +is( + $url->hostname, + 'relog.ch', + '$url->hostname' +); + +is( + $url->realhostname, + 'www.relog.ch', + '$url->realhostname' +); + +is( + $url->port, + 80, + '$url->port' +); + +is( + $url->path, + '', + '$url->path' +); + +is( + $url->user, + 'falcon', + '$url->user' +); + +is( + $url->pass, + 'joshua', + '$url->pass' +); + +# and now check for path +$url = new it_url('HTTP://falcon:joshua@www.Relog.CH:80/foo/bar.html'); + +is( + $url->path, + 'foo/bar.html', + '$url->path' +); + +$_SERVER['HTTP_HOST'] = "gna.ch"; +is( + it_url::absolute("/"), + 'http://gna.ch:/', + 'it_url::absolute basic' +); + +$_SERVER['SERVER_PORT'] = 42; +is( + it_url::absolute("/port"), + 'http://gna.ch:42/port', + 'it_url::absolute with non-standard port' +); + +$_SERVER['HTTPS'] = true; +$_SERVER['SERVER_PORT'] = 443; +is( + it_url::absolute("/https"), + 'https://gna.ch/https', + 'it_url::absolute for https' +); + +$url = new it_url('http://www.gna.ch/'); +$page = $url->get(); +is( + it::match('(</html>)', $page), + '</html>', + '$url->get with url in constructor' +); + +$url = new it_url('http://bogus.url'); +$page = $url->get('http://www.gna.ch/'); +is( + it::match('(</html>)', $page), + '</html>', + '$url->get(url) with url as string arg' +); + +$url = new it_url('http://bogus.url'); +$page = $url->get(array('url' => 'http://www.gna.ch/')); +is( + it::match('(</html>)', $page), + '</html>', + '$url->get(\'url\' => url) with url as named arg' +); +is( + $url->result, + 200, + '$url->result = 200' +); +is( + $url->headers['Connection'], + 'close', + '$url->headers correctly set' +); + +unset($url, $page); +$page = it_url::get('http://www.gna.ch/'); +is( + it::match('(</html>)', $page), + '</html>', + 'it_url::get() static call' +); + +$pages = it_url::get_multi('urls' => array('a' => 'http://www.gna.ch/', 'b' => 'http://search.ch/')); +ok(it::match('</html>', $pages['a']), 'it_url::get_multi got first url'); +ok(it::match('</html>', $pages['b']), 'it_url::get_multi got second url'); +is(count($pages), 2, 'it_url::get_multi no additional array elements'); + +?> |