diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/it.t | 27 | ||||
-rwxr-xr-x | tests/it_url.t | 42 | ||||
-rwxr-xr-x | tests/it_url_slow.t | 18 |
3 files changed, 44 insertions, 43 deletions
@@ -58,25 +58,25 @@ match( match( '\bblah\b', 'ablahc', - false, + null, 'don\'t match \b at word chars' ); match( '\bblah\b', 'Üblahä', - false, + null, 'don\'t match \b at umlaute' ); match( '\Bblah\B', ' blah ', - false, + null, 'don\'t match \B at spaces' ); match( '\Bblah\B', 'blah', - false, + null, 'don\'t match \B at end of string' ); @@ -112,7 +112,7 @@ match( match( '\ba', 'äa', - '', + null, '\b must know umlauts' ); @@ -133,19 +133,19 @@ $escapedwordregex = preg_replace('|[\\\\/]|', '', $escapedwordregex); match( '\\\\w+', $escapedwordregex, - false, + null, 'don\'t parse \w in \\\\w at beginning (no match)' ); match( 'aaa\\\\w+', 'aaa' . $escapedwordregex, - false, + null, 'don\'t parse \w in \\\\w after chars (no match)' ); match( '\\\\\\\\w+', '\\' . $escapedwordregex, - false, + null, 'don\'t parse \w in \\\\\\\w (no match)' ); @@ -157,7 +157,7 @@ match( match( '[\w]+', '[[[]]]---', - false, + null, 'replace \w in [\w] correctly (no match)' ); @@ -169,7 +169,7 @@ match( match( '[\\\\w]+', ' blabergna ', - false, + null, 'don\'t parse \w in [\\\\w] (no match)' ); @@ -239,9 +239,9 @@ match( match( 'abc', "aBc", - false, + null, "set case sensitivity by parameter", - array('casesensitive' => 1), + array('casesensitive' => 1) ); match( @@ -309,7 +309,7 @@ is(it::replace(array('a' => "b", 'b' => "c"), "a"), "c"); is(it::grep('ismatch', array('ismatch', 'isnomatch')), array('ismatch'), 'grep with simple regex'); is(it::grep('!', array('ismatch!', 'isnomatch')), array('ismatch!'), '! in regex'); -is(it::grep('lower|UPPER', array('lower', 'LOWER', 'upper', 'UPPER'), 'casesensitive' => 1), array(0 => 'lower', 3 => 'UPPER'), 'set casesensitive'); +is(it::grep('lower|UPPER', array('lower', 'LOWER', 'upper', 'UPPER'), array('casesensitive' => 1)), array(0 => 'lower', 3 => 'UPPER'), 'set casesensitive'); is(it::grep('match', array('foo' => 'match', 'bar' => 'gna')), array('foo' => 'match'), 'with keys'); setlocale(LC_CTYPE, $oldlocale); @@ -389,6 +389,7 @@ is(it::any2utf8("a💚b"), "a💚b", "it::any2utf8 correctly handles 4-byte utf- is(it::any2utf8(array("foo", utf8_decode("bär"))), array("foo", "bär"), "any2utf8 on arrays"); is(it::any2utf8(array("foo", array(utf8_decode("bär")))), array("foo", array("bär")), "any2utf8 on recursive arrays"); is(it::any2utf8(array(1, true, false, null)), array(1, true, false, null), "any2utf8 should leave types alone"); +is(it::any2utf8(array(utf8_decode('Müller') => utf8_decode('Müller'))), array('Müller' => 'Müller'), "it::any2utf8 latin1 keys"); foreach (array($dummy, false, true, null, 1, "a", "Ä", "/", array()) as $var) is(it::json_decode(it::json_encode($var)), $var); diff --git a/tests/it_url.t b/tests/it_url.t index 711b5f1..5cb2b29 100755 --- a/tests/it_url.t +++ b/tests/it_url.t @@ -109,7 +109,7 @@ ok( ); is( $url->result, - 200, + '200', '$url->result = 200' ); is( @@ -131,7 +131,7 @@ handle_server( is( it_url::get('http://localhost:8000/'), "Testserver root output", - 'it_url::get() static call with port', + 'it_url::get() static call with port' ) ); @@ -139,7 +139,7 @@ handle_server( is( it_url::get(array('url' => 'http://localhost:8000/', 'maxlength' => 100)), "Testserver root output", - 'it_url::get() static call with port and maxlength', + 'it_url::get() static call with port and maxlength' ) ); @@ -147,7 +147,7 @@ handle_server( is( it_url::get(array('url' => 'http://localhost:8000/', 'maxlength' => 5)), false, - 'it_url::get() static call with port and too small maxlength', + 'it_url::get() static call with port and too small maxlength' ) ); @@ -155,7 +155,7 @@ handle_server( is( it_url::get('http://localhost:8000/temp_redirect'), "Testserver output after temporary redirect", - 'it_url::get() follows temproary redirect', + 'it_url::get() follows temproary redirect' ) ); @@ -163,7 +163,7 @@ handle_server( is( it_url::get('http://localhost:8000/perm_redirect'), "Testserver output after permanent redirect", - 'it_url::get() follows permanent redirect', + 'it_url::get() follows permanent redirect' ) ); @@ -171,7 +171,7 @@ handle_server( is( it_url::get('http://localhost:8000/relative_redirect'), "Testserver output after relative redirect", - 'TODO: it_url::get() follows relative redirect correctly', + 'TODO: it_url::get() follows relative redirect correctly' ) ); @@ -179,59 +179,59 @@ handle_server( is( it_url::get('http://localhost:8000/nohost_redirect'), "Testserver output after nohost redirect", - 'TODO: it_url::get() follows redirect without host correctly', + 'TODO: it_url::get() follows redirect without host correctly' ) ); $output = handle_server( ok( - !it_url::get(U('http://localhost:8000/redirect_loop', 'num' => 10)), - 'it_url::get() handles redirect loop', + !it_url::get(U('http://localhost:8000/redirect_loop', array('num' => 10))), + 'it_url::get() handles redirect loop' ) ); $last_num = it::match('num=(\d+)', end($output)); if (!ok( $last_num == 5, - 'it_url::get() aborts redirect loop after 5 redirects', + 'it_url::get() aborts redirect loop after 5 redirects' )) diag($output); $output = handle_server( ok( - !it_url::get('url' => 'http://localhost:8000/does_not_exist', 'retries' => 4), - 'it_url::get() retries on empty response', + !it_url::get(array('url' => 'http://localhost:8000/does_not_exist', 'retries' => 4)), + 'it_url::get() retries on empty response' ) ); if (!ok( count(preg_grep('/^Got Request:/', $output)) == 5, - 'it_url::get() respects set retry count', + 'it_url::get() respects set retry count' )) diag($output); handle_server( is( - it_url::get(U('http://localhost:8000/get_server_value', 'key' => 'HTTP_HOST')), + it_url::get(U('http://localhost:8000/get_server_value', array('key' => 'HTTP_HOST'))), 'localhost:8000', - 'it_url::get() sets correct Host header', + 'it_url::get() sets correct Host header' ) ); handle_server( is( - it_url::get(U('http://localhost:8000/get_server_value', 'key' => 'HTTP_ACCEPT_LANGUAGE')), + it_url::get(U('http://localhost:8000/get_server_value', array('key' => 'HTTP_ACCEPT_LANGUAGE'))), T_lang(), - 'it_url::get() sets correct Accept-Language header', + 'it_url::get() sets correct Accept-Language header' ) ); handle_server( ok( - it::match('Mozilla', it_url::get(U('http://localhost:8000/get_server_value', 'key' => 'HTTP_USER_AGENT'))), - 'it_url::get() sets User-Agent containing Mozilla', + it::match('Mozilla', it_url::get(U('http://localhost:8000/get_server_value', array('key' => 'HTTP_USER_AGENT')))), + 'it_url::get() sets User-Agent containing Mozilla' ) ); -$pages = it_url::get_multi('urls' => array('a' => 'http://www.gna.ch/', 'b' => 'http://search.ch/')); +$pages = it_url::get_multi(array('urls' => array('a' => 'http://www.gna.ch/', 'b' => 'http://search.ch/'))); ok(strpos($pages['a'], '</html>'), 'it_url::get_multi got first url'); # UTF8SAFE ok(strpos($pages['b'], '</html>'), 'it_url::get_multi got second url'); # UTF8SAFE is(count($pages), 2, 'it_url::get_multi no additional array elements'); diff --git a/tests/it_url_slow.t b/tests/it_url_slow.t index 74440ce..68d68c1 100755 --- a/tests/it_url_slow.t +++ b/tests/it_url_slow.t @@ -11,18 +11,18 @@ handle_server( is( it_url::get('http://localhost:8000/short_sleep'), "Testserver output after short sleep", - 'it_url::get() waits for 4 seconds', + 'it_url::get() waits for 4 seconds' ) ); $start = microtime(true); $res = ok( !it_url::get(array('url' => 'http://localhost:8000/long_sleep', 'timeout' => 5, 'retries' => 0)), - 'it_url::get() fails after timeout seconds with no output', + 'it_url::get() fails after timeout seconds with no output' ); $res2 = is( - floor(microtime(true) - $start), 5, - '... and fails as soon as timeout is surpassed', + intval(microtime(true) - $start), 5, + '... and fails as soon as timeout is surpassed' ); sleep(1); # wait for testserver $output = server_output(); @@ -33,17 +33,17 @@ handle_server( is( it_url::get('http://localhost:8000/slow_response'), join('', it::map('"Testserver slow output $v\n"', range(0, 5))), - 'it_url::get() waits for slow response with continuous output', + 'it_url::get() waits for slow response with continuous output' ) ); $start = microtime(true); $res = ok( !it_url::get(array('url' => 'http://localhost:8000/slow_response', 'totaltimeout' => 5, 'retries' => 0)), - 'it_url::get() fails for response slower than totaltimeout', + 'it_url::get() fails for response slower than totaltimeout' ); $res2 = is( - floor(microtime(true) - $start), 5, + intval(microtime(true) - $start), 5, '... and fails as soon as totaltimeout is surpassed' ); sleep(1); # wait for testserver @@ -53,8 +53,8 @@ if (!$res || !$res2) handle_server( ok( - it_url::get(U('http://localhost:8000/repeat', 'string' => "abc", 'num' => 1024 * 1024)) == str_repeat("abc", 1024 * 1024), - 'it_url::get() handles large response', + it_url::get(U('http://localhost:8000/repeat', array('string' => "abc", 'num' => 1024 * 1024))) == str_repeat("abc", 1024 * 1024), + 'it_url::get() handles large response' ) ); |