From 4cdbcad35dd2bcf11acc452e4ca9f6d8737853e0 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 12 Oct 2026 18:14:14 +0200 Subject: Migrate test function is() to is_() to fix PHP 8.6 warning --- test/autoprepend.t | 10 +- test/exec.t | 58 ++++----- test/getopt.t | 2 +- test/it.t | 360 ++++++++++++++++++++++++++--------------------------- test/it_cache.t | 22 ++-- test/it_dbi.t | 220 ++++++++++++++++---------------- test/it_error.t | 4 +- test/it_html.t | 126 +++++++++---------- test/it_mail.t | 44 +++---- test/it_pipe.t | 60 ++++----- test/it_text.t | 32 ++--- test/it_url.t | 106 ++++++++-------- test/it_url_slow.t | 10 +- test/it_xml.t | 4 +- test/itjs.t | 20 +-- 15 files changed, 539 insertions(+), 539 deletions(-) diff --git a/test/autoprepend.t b/test/autoprepend.t index 287bdff..7aedeaa 100755 --- a/test/autoprepend.t +++ b/test/autoprepend.t @@ -7,31 +7,31 @@ $GLOBALS['it_text']->statictext = [ 'foo' => ["de" => "bar {v1}", "en" => "qux {v1}"], ]; -is( +is_( T('foo'), "bar ", "simple T()" ); -is( +is_( T('foo', 'en'), "qux ", "simple T() with language" ); -is( +is_( T('foo', ['v1' => "gna "gna "gna 'gnu'], ['arg' => "gna"]), "gna\n", "exec with argument"); -is(it::exec("echo {0}", 'gna'), "gna\n", "exec with positional argument"); -is(it::shell_command("egrep a{10}"), 'egrep a{10}', "exec with too large positional argument"); -is(it::shell_command("echo {arg}", ['arg' => 'gna07,-:blah']), "echo gna07,-:blah", "don't quote arguments with only whitelistes characters"); -is(it::shell_command("echo {arg}", ['arg' => '2>&1']), "echo '2>&1'", "quote arguments with dangerous characters"); -is(it::shell_command("echo {arg}", ['arg' => '']), "echo ''", "quote empty arguments"); -is(it::shell_command("echo {arg}", ['arg' => null]), "echo ", "remove null values"); -is(it::shell_command("echo {arg}", ['arg' => false]), "echo ", "remove false values"); -is(it::shell_command("echo {arg}", ['arg' => []]), "echo ", "remove empty arrays"); -is(it::shell_command("echo {arg}", (object)['arg' => "foo"]) , "echo foo", "allow objects"); -is(it::shell_command("echo {arg}", ['arg' => 1], ['arg' => 2]), "echo 2", "support varargs"); +is_(it::exec("echo gna"), "gna\n", "basic exec"); +is_(it::exec("echo {arg}", ['arg' => 'gnu'], ['arg' => "gna"]), "gna\n", "exec with argument"); +is_(it::exec("echo {0}", 'gna'), "gna\n", "exec with positional argument"); +is_(it::shell_command("egrep a{10}"), 'egrep a{10}', "exec with too large positional argument"); +is_(it::shell_command("echo {arg}", ['arg' => 'gna07,-:blah']), "echo gna07,-:blah", "don't quote arguments with only whitelistes characters"); +is_(it::shell_command("echo {arg}", ['arg' => '2>&1']), "echo '2>&1'", "quote arguments with dangerous characters"); +is_(it::shell_command("echo {arg}", ['arg' => '']), "echo ''", "quote empty arguments"); +is_(it::shell_command("echo {arg}", ['arg' => null]), "echo ", "remove null values"); +is_(it::shell_command("echo {arg}", ['arg' => false]), "echo ", "remove false values"); +is_(it::shell_command("echo {arg}", ['arg' => []]), "echo ", "remove empty arrays"); +is_(it::shell_command("echo {arg}", (object)['arg' => "foo"]) , "echo foo", "allow objects"); +is_(it::shell_command("echo {arg}", ['arg' => 1], ['arg' => 2]), "echo 2", "support varargs"); errlike(fn() => it::shell_command('echo -- $(echo {arg})', ['arg' => "-1"]), "leading - in value", "disallow leading dash in non-option args"); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['--longopt' => true]]), "echo --longopt", "options argument with long option" ); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['-onedash' => true]]), "echo -onedash", "... with long option but only one dash" ); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['-s' => true]]), "echo -s", "... with short option" ); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['--longopt' => 'val']]), "echo --longopt val", "... with long option with value" ); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['-onedash' => 'val']]), "echo -onedash val", "... with long option but only one dash and with value" ); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['-s' => 'val']]), "echo -s val", "... with short option with value" ); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['--longopt' => false]]), "echo ", "... with disabled long option" ); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['-s' => false]]), "echo ", "... with disabled short option" ); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['longopt' => true]]), "echo --longopt", "... long option without dashes" ); -is( +is_( it::shell_command("echo {-opts}", ['-opts' => ['s' => true]]), "echo -s", "... short option without dashes" @@ -75,16 +75,16 @@ foreach (["", "C", "de_CH", "de_CH.utf8"] as $locale) $arg = "preüpost"; if (it::match('utf8', $locale)) $arg = it::any2utf8($arg); - is(it::exec("echo {arg}", ['arg' => $arg]), $arg . "\n", "exec with argument and umlaut (locale '$locale')"); + is_(it::exec("echo {arg}", ['arg' => $arg]), $arg . "\n", "exec with argument and umlaut (locale '$locale')"); } -is(it::_exec_quotevalue(""), "''", "empty arg needs quotes"); -is(it::_exec_quotevalue("*"), "'*'", "special chars need quotes"); -is(it::_exec_quotevalue("Aabcdef0123456789"), "Aabcdef0123456789", "simple case. tel:debug_getdata needs unquoted vals"); +is_(it::_exec_quotevalue(""), "''", "empty arg needs quotes"); +is_(it::_exec_quotevalue("*"), "'*'", "special chars need quotes"); +is_(it::_exec_quotevalue("Aabcdef0123456789"), "Aabcdef0123456789", "simple case. tel:debug_getdata needs unquoted vals"); -is(it::system('exit 0'), 0, 'return exit code 0'); -is(it::system('exit 1'), 1, 'return exit code 1'); -is(it::system('exit -1'), 255, 'return exit code unsigned'); +is_(it::system('exit 0'), 0, 'return exit code 0'); +is_(it::system('exit 1'), 1, 'return exit code 1'); +is_(it::system('exit -1'), 255, 'return exit code unsigned'); @unlink('/tmp/it_system_test'); it::system('touch /tmp/it_system_test'); diff --git a/test/getopt.t b/test/getopt.t index 380d0fd..4894819 100755 --- a/test/getopt.t +++ b/test/getopt.t @@ -16,7 +16,7 @@ function getopt_ok($argv, $exp, $name) { $_SERVER['argv'] = array_merge(['doesnotexist.php'], $argv); $got = it::getopt($GLOBALS['usage'], ['noexit' => true]); - return is($got, $exp, $name); + return is_($got, $exp, $name); } foreach (["" => "blah gnaber", " (umlaute)" => "pre üäpost"] as $variant => $testarg) diff --git a/test/it.t b/test/it.t index bbda730..c74abef 100755 --- a/test/it.t +++ b/test/it.t @@ -15,7 +15,7 @@ setlocale(LC_CTYPE, 'de_CH'); # required becuase we're checking German umlauts function _match($regex, $string, $expect, $name, $p = []) { $GLOBALS['TEST_MORE_LEVEL'] = 1; - $pass = is (it::match($regex, $string, $p), $expect, $name); + $pass = is_(it::match($regex, $string, $p), $expect, $name); if (!$pass) { diag(" regex given: $regex" . ($p ? " " .D($p) : "")); @@ -290,7 +290,7 @@ ini_set('default_charset', 'utf-8'); # # tests for it::replace() # -is( +is_( it::replace( [ 'regex1' => 'repl1', @@ -301,79 +301,79 @@ is( 'test tr regex function' ); -is(it::replace(['a' => "1", 'b' => "2"], "ab"), "12"); -is(it::replace(['!' => "x"], "!"), "x"); -is(it::replace(['\w' => "x"], "oö"), "xx"); -is(it::replace(['[[:alpha:]]' => "x"], "ö"), "x"); -is(it::replace(['\w' => "x", '#' => "!"], "#ö"), "!x"); -is(it::replace(['#' => "!", '\w' => "x"], "#ö"), "!x"); -is(it::replace(['ö' => "x"], "Ö"), "x"); -is(it::replace(['a' => "1"], "aaa", ['limit' => 1]), "1aa"); -is(it::replace(['\s' => "x"], it_html::entity_decode(" ")), "x", "match non-breaking space as white-space character"); -is(it::replace(['a' => "b", 'b' => "c"], "a"), "c"); +is_(it::replace(['a' => "1", 'b' => "2"], "ab"), "12"); +is_(it::replace(['!' => "x"], "!"), "x"); +is_(it::replace(['\w' => "x"], "oö"), "xx"); +is_(it::replace(['[[:alpha:]]' => "x"], "ö"), "x"); +is_(it::replace(['\w' => "x", '#' => "!"], "#ö"), "!x"); +is_(it::replace(['#' => "!", '\w' => "x"], "#ö"), "!x"); +is_(it::replace(['ö' => "x"], "Ö"), "x"); +is_(it::replace(['a' => "1"], "aaa", ['limit' => 1]), "1aa"); +is_(it::replace(['\s' => "x"], it_html::entity_decode(" ")), "x", "match non-breaking space as white-space character"); +is_(it::replace(['a' => "b", 'b' => "c"], "a"), "c"); -is(it::grep('ismatch', ['ismatch', 'isnomatch']), ['ismatch'], 'grep with simple regex'); -is(it::grep('!', ['ismatch!', 'isnomatch']), ['ismatch!'], '! in regex'); -is(it::grep('lower|UPPER', ['lower', 'LOWER', 'upper', 'UPPER'], ['casesensitive' => 1]), [0 => 'lower', 3 => 'UPPER'], 'set casesensitive'); -is(it::grep('match', ['foo' => 'match', 'bar' => 'gna']), ['foo' => 'match'], 'with keys'); -is(it::grep('2', [0 => 1, 1 => 2, 2 => 3], ['invert' => true]), [0 => 1, 2 => 3]); +is_(it::grep('ismatch', ['ismatch', 'isnomatch']), ['ismatch'], 'grep with simple regex'); +is_(it::grep('!', ['ismatch!', 'isnomatch']), ['ismatch!'], '! in regex'); +is_(it::grep('lower|UPPER', ['lower', 'LOWER', 'upper', 'UPPER'], ['casesensitive' => 1]), [0 => 'lower', 3 => 'UPPER'], 'set casesensitive'); +is_(it::grep('match', ['foo' => 'match', 'bar' => 'gna']), ['foo' => 'match'], 'with keys'); +is_(it::grep('2', [0 => 1, 1 => 2, 2 => 3], ['invert' => true]), [0 => 1, 2 => 3]); setlocale(LC_CTYPE, $oldlocale); ini_set('default_charset', $oldcharset); # end of tests that must run with specific charset # it::cidr_match tests -is(it::cidr_match('192.168.2.3', '192.168.2.5'), false, "cidr_match full IP no match no mask"); -is(it::cidr_match('192.168.2.3', '192.168.2.3'), '192.168.2.3', "cidr_match full IP match no mask"); -is(it::cidr_match('192.168.2.3', '192.168.2.5/32'), false, "cidr_match full IP no match"); -is(it::cidr_match('192.168.2.5', '192.168.2.5/32'), '192.168.2.5/32', "cidr_match full IP match"); -is(it::cidr_match('192.168.1.1', '192.168.42.0/24'), false, "cidr_match no match"); -is(it::cidr_match('192.168.42.1', '192.168.42.0/24'), '192.168.42.0/24', "cidr_match basic match"); -is(it::cidr_match('192.168.42.42', '192.168.0.0/16'), '192.168.0.0/16', "cidr_match class b"); -is(it::cidr_match('192.168.42.42', '192.168.42.64/26'), false, "cidr_match offset no match"); -is(it::cidr_match('192.168.42.42', '192.168.42.32/27'), '192.168.42.32/27', "cidr_match offset"); -is(it::cidr_match('2001:918:ff83:101:798e:77c0:b722:fe56', '2001:918:ff83:101::/64'), '2001:918:ff83:101::/64', "cidr_match ipv6"); -is(it::cidr_match('2001:918:ff83:102:798e:77c0:b722:fe56', '2001:918:ff83:101::/64'), false, "cidr_match ipv6 no match" ); -is(it::cidr_match('10.11.12.13', ['10.0.0.0/8', '192.168.0.0./16']), '10.0.0.0/8', "cidr_match array"); +is_(it::cidr_match('192.168.2.3', '192.168.2.5'), false, "cidr_match full IP no match no mask"); +is_(it::cidr_match('192.168.2.3', '192.168.2.3'), '192.168.2.3', "cidr_match full IP match no mask"); +is_(it::cidr_match('192.168.2.3', '192.168.2.5/32'), false, "cidr_match full IP no match"); +is_(it::cidr_match('192.168.2.5', '192.168.2.5/32'), '192.168.2.5/32', "cidr_match full IP match"); +is_(it::cidr_match('192.168.1.1', '192.168.42.0/24'), false, "cidr_match no match"); +is_(it::cidr_match('192.168.42.1', '192.168.42.0/24'), '192.168.42.0/24', "cidr_match basic match"); +is_(it::cidr_match('192.168.42.42', '192.168.0.0/16'), '192.168.0.0/16', "cidr_match class b"); +is_(it::cidr_match('192.168.42.42', '192.168.42.64/26'), false, "cidr_match offset no match"); +is_(it::cidr_match('192.168.42.42', '192.168.42.32/27'), '192.168.42.32/27', "cidr_match offset"); +is_(it::cidr_match('2001:918:ff83:101:798e:77c0:b722:fe56', '2001:918:ff83:101::/64'), '2001:918:ff83:101::/64', "cidr_match ipv6"); +is_(it::cidr_match('2001:918:ff83:102:798e:77c0:b722:fe56', '2001:918:ff83:101::/64'), false, "cidr_match ipv6 no match" ); +is_(it::cidr_match('10.11.12.13', ['10.0.0.0/8', '192.168.0.0./16']), '10.0.0.0/8', "cidr_match array"); # it::is_private_ip tests -is(it::is_private_ip('192.168.2.3'), true, "is_private_ip 192.168/16 example"); -is(it::is_private_ip('34.98.92.95'), false, "is_private_ip search.ch ipv4"); -is(it::is_private_ip('2600:1901:0:6fe0::'), false, "is_private_ip search.ch ipv6"); -is(it::is_private_ip('::1'), true, "is_private_ip loopback ipv6"); -is(it::is_private_ip('172.19.34.19'), true, "is_private_ip 172.16/12 example"); -is(it::is_private_ip('10.128.72.9'), true, "is_private_ip 10/8 example"); -is(it::is_private_ip('195.49.47.11'), false, "is_private_ip gna.ch ipv4"); -is(it::is_private_ip('2a01:2a8:9100:1911:abba:0:1:80'), false, "is_private_ip gna.ch ipv6"); -is(it::is_private_ip('fd12::1337:bab3:d00d'), true, "is_private_ip fc00::/7 example"); -is(it::is_private_ip('81.6.43.252'), false, "is_private_ip dunstkreis.ch ipv4"); -is(it::is_private_ip('2a02:169:200:d::15'), false, "is_private_ip dunstkreis.ch ipv6"); -is(it::is_private_ip('127.6.7.23'), true, "is_private_ip loopback ipv4"); -is(it::is_private_ip('169.254.6.9'), true, "is_private_ip 169.254/16 example"); -is(it::is_private_ip('gna.ch'), false, "is_private_ip gna.ch"); -is(it::is_private_ip('dunstkreis.ch'), false, "is_private_ip dunstkreis.ch"); -is(it::is_private_ip('loopback.gna.ch'), true, "is_private_ip loopback.gna.ch points to ::1"); -is(it::is_private_ip('cname.gna.ch'), true, "is_private_ip cname.gna.ch points to loopback.gna.ch"); -is(it::is_private_ip('pub4.gna.ch'), true, "is_private_ip pub4.gna.ch has public ipv4 but private ipv6"); -is(it::is_private_ip('pub6.gna.ch'), true, "is_private_ip pub6.gna.ch has public ipv6 but private ipv4"); +is_(it::is_private_ip('192.168.2.3'), true, "is_private_ip 192.168/16 example"); +is_(it::is_private_ip('34.98.92.95'), false, "is_private_ip search.ch ipv4"); +is_(it::is_private_ip('2600:1901:0:6fe0::'), false, "is_private_ip search.ch ipv6"); +is_(it::is_private_ip('::1'), true, "is_private_ip loopback ipv6"); +is_(it::is_private_ip('172.19.34.19'), true, "is_private_ip 172.16/12 example"); +is_(it::is_private_ip('10.128.72.9'), true, "is_private_ip 10/8 example"); +is_(it::is_private_ip('195.49.47.11'), false, "is_private_ip gna.ch ipv4"); +is_(it::is_private_ip('2a01:2a8:9100:1911:abba:0:1:80'), false, "is_private_ip gna.ch ipv6"); +is_(it::is_private_ip('fd12::1337:bab3:d00d'), true, "is_private_ip fc00::/7 example"); +is_(it::is_private_ip('81.6.43.252'), false, "is_private_ip dunstkreis.ch ipv4"); +is_(it::is_private_ip('2a02:169:200:d::15'), false, "is_private_ip dunstkreis.ch ipv6"); +is_(it::is_private_ip('127.6.7.23'), true, "is_private_ip loopback ipv4"); +is_(it::is_private_ip('169.254.6.9'), true, "is_private_ip 169.254/16 example"); +is_(it::is_private_ip('gna.ch'), false, "is_private_ip gna.ch"); +is_(it::is_private_ip('dunstkreis.ch'), false, "is_private_ip dunstkreis.ch"); +is_(it::is_private_ip('loopback.gna.ch'), true, "is_private_ip loopback.gna.ch points to ::1"); +is_(it::is_private_ip('cname.gna.ch'), true, "is_private_ip cname.gna.ch points to loopback.gna.ch"); +is_(it::is_private_ip('pub4.gna.ch'), true, "is_private_ip pub4.gna.ch has public ipv4 but private ipv6"); +is_(it::is_private_ip('pub6.gna.ch'), true, "is_private_ip pub6.gna.ch has public ipv6 but private ipv4"); # Stuff which is interpreted by curl -is(it::is_private_ip('127.1'), true, "is_private_ip loopback ipv4 (zeroes omitted)"); -is(it::is_private_ip('127.0.0.01'), true, "is_private_ip loopback ipv4 (octal)"); -is(it::is_private_ip('127.0.0.0x1'), true, "is_private_ip loopback ipv4 (hexadecimal)"); -is(it::is_private_ip('127.01.0x1'), true, "is_private_ip private with omissions, octal and hexadecimal"); -is(it::is_private_ip('128.01.0x1'), false, "TODO: is_private_ip non-private with omissions, octal and hexadecimal"); +is_(it::is_private_ip('127.1'), true, "is_private_ip loopback ipv4 (zeroes omitted)"); +is_(it::is_private_ip('127.0.0.01'), true, "is_private_ip loopback ipv4 (octal)"); +is_(it::is_private_ip('127.0.0.0x1'), true, "is_private_ip loopback ipv4 (hexadecimal)"); +is_(it::is_private_ip('127.01.0x1'), true, "is_private_ip private with omissions, octal and hexadecimal"); +is_(it::is_private_ip('128.01.0x1'), false, "TODO: is_private_ip non-private with omissions, octal and hexadecimal"); # it::filter_keys tests $data = ['a' => 1, 'b' => 2, 'c' => 3]; -is(it::filter_keys($data, 'a'), ['a' => 1], "select one key"); -is(it::filter_keys($data, ['a', 'b']), ['a' => 1, 'b' => 2], "select two keys with array"); -is(it::filter_keys($data, 'a,b'), ['a' => 1, 'b' => 2], "select two keys with string"); -is( +is_(it::filter_keys($data, 'a'), ['a' => 1], "select one key"); +is_(it::filter_keys($data, ['a', 'b']), ['a' => 1, 'b' => 2], "select two keys with array"); +is_(it::filter_keys($data, 'a,b'), ['a' => 1, 'b' => 2], "select two keys with string"); +is_( array_keys(it::filter_keys($data, 'b,a')), ['a', 'b'], "keep order of data array per default"); -is( +is_( array_keys(it::filter_keys($data, 'b,a', ['reorder' => true])), ['b', 'a'], "reorder with given key order"); @@ -383,7 +383,7 @@ is( function _time($debug_time, $expected) { $GLOBALS['debug_time'] = $debug_time; - is(it::date(), $expected, ".time-$debug_time"); + is_(it::date(), $expected, ".time-$debug_time"); $GLOBALS['debug_time'] = ''; } _time("2014-01-01", "2014-01-01 00:00:00"); @@ -394,165 +394,165 @@ _time("15-27-15", it::date('', '15:27:15')); _time("152715", it::date('', '15:27:15')); _time("yesterday", it::date('', 'yesterday')); -is(it::date('date', '2011-10-25'), '25.10.2011', 'parse date string with strtotime'); -is(it::date('date', '2011-10-25 + 3 days'), '28.10.2011', 'date arithmetic (add)'); -is(it::date('date', '2011-10-25 - 3 days'), '22.10.2011', 'date arithmetic (subtract)'); -is(it::date('date', '2011-10-25 +-3 days'), '22.10.2011', 'date arithmetic (negative value)'); -is(it::date('date', '2011-10-25 --3 days'), '28.10.2011', 'date arithmetic (double negative)'); -is(it::date('date', '2011-10-25 ++ 3 days'), '28.10.2011', 'date arithmetic (double positive with space)'); -is(it::date('date', '2011-10-25 -+ 3 days'), '22.10.2011', 'date arithmetic (negative positive with space)'); -is(it::date('datetime', '2011-10-25 +12 hours +30 minutes'), '25.10.2011 12:30', 'datetime arithmetic (hours minutes)'); -is(it::date('datetime', '2011-10-25 +24 hours +30 minutes'), '26.10.2011 00:30', 'datetime arithmetic (hours minutes over midnight)'); -is(it::date('datetime', '2011-10-25 8:00 +10 minutes'), '25.10.2011 08:10', 'time arithmetic (add)'); -is(it::date('datetime', '2011-10-25 8:00 -10 minutes'), '25.10.2011 07:50', 'time arithmetic (subtract)'); -is(it::date('datetime', '2011-10-25 8:00 +-10 minutes'), '25.10.2011 07:50', 'time arithmetic (negative value)'); -is(it::date('datetime', '2011-10-25 8:00 --10 minutes'), '25.10.2011 08:10', 'time arithmetic (double negative)'); -is(it::date('datetime', '2011-10-25 --1 month --3 days 8:00 +- 4 hours +-10 minutes'), '28.11.2011 03:50', 'date and time arithmetic (multiple signs)'); -is(it::date('datetime', it::time()), it::date('datetime'), 'recognize int as timestamp'); -is(it::date('datetime', it::time()*1.0), it::date('datetime'), 'recognize float as timestamp'); -is(it::date('datetime', it::time() . ''), it::date('datetime'), 'recognize digit string as timestamp'); -is(it::date('datetime', '@' . it::time()), it::date('datetime'), 'recognize strtotime timestamp format'); -is(it::date('datetime', 10), it::date('datetime', "10"), 'numeric and string give same result'); -is(it::date('datetime', 10.0), it::date('datetime', "10"), '... as long as num is properly truncated'); -is(it::date('datetime', 10.5), it::date('datetime', "10"), '... with one digit after point'); -is(it::date('datetime', 10.56), it::date('datetime', "10"), '... with two digits after point'); -is(it::date('datetime', 1000000), it::date('datetime', "1000000"), '... large nummer'); -is(it::date('datetime', 1000000.543), it::date('datetime', "1000000"), '... large nummer and point'); -is(it::date('time', "10.5"), "10:05", 'interpret string with points with strtotime'); -is(it::date('time', "10.05"), "10:05", 'interpret string with points with strtotime'); -is(it::date('Y-m-d', "20000101"), '2000-01-01', 'interpret 8 digit strings as dates'); -is(it::date('Y-m-d', 20000101), '2000-01-01', 'interpret 8 numbers strings as dates'); -is(it::date('Y-m-d', "20990101"), '2099-01-01', 'interpret 8 digit strings as dates'); -is(it::date('Y-m-d', strtotime("1980-01-01")), '1980-01-01', 'interpret typical time stamps correctly'); +is_(it::date('date', '2011-10-25'), '25.10.2011', 'parse date string with strtotime'); +is_(it::date('date', '2011-10-25 + 3 days'), '28.10.2011', 'date arithmetic (add)'); +is_(it::date('date', '2011-10-25 - 3 days'), '22.10.2011', 'date arithmetic (subtract)'); +is_(it::date('date', '2011-10-25 +-3 days'), '22.10.2011', 'date arithmetic (negative value)'); +is_(it::date('date', '2011-10-25 --3 days'), '28.10.2011', 'date arithmetic (double negative)'); +is_(it::date('date', '2011-10-25 ++ 3 days'), '28.10.2011', 'date arithmetic (double positive with space)'); +is_(it::date('date', '2011-10-25 -+ 3 days'), '22.10.2011', 'date arithmetic (negative positive with space)'); +is_(it::date('datetime', '2011-10-25 +12 hours +30 minutes'), '25.10.2011 12:30', 'datetime arithmetic (hours minutes)'); +is_(it::date('datetime', '2011-10-25 +24 hours +30 minutes'), '26.10.2011 00:30', 'datetime arithmetic (hours minutes over midnight)'); +is_(it::date('datetime', '2011-10-25 8:00 +10 minutes'), '25.10.2011 08:10', 'time arithmetic (add)'); +is_(it::date('datetime', '2011-10-25 8:00 -10 minutes'), '25.10.2011 07:50', 'time arithmetic (subtract)'); +is_(it::date('datetime', '2011-10-25 8:00 +-10 minutes'), '25.10.2011 07:50', 'time arithmetic (negative value)'); +is_(it::date('datetime', '2011-10-25 8:00 --10 minutes'), '25.10.2011 08:10', 'time arithmetic (double negative)'); +is_(it::date('datetime', '2011-10-25 --1 month --3 days 8:00 +- 4 hours +-10 minutes'), '28.11.2011 03:50', 'date and time arithmetic (multiple signs)'); +is_(it::date('datetime', it::time()), it::date('datetime'), 'recognize int as timestamp'); +is_(it::date('datetime', it::time()*1.0), it::date('datetime'), 'recognize float as timestamp'); +is_(it::date('datetime', it::time() . ''), it::date('datetime'), 'recognize digit string as timestamp'); +is_(it::date('datetime', '@' . it::time()), it::date('datetime'), 'recognize strtotime timestamp format'); +is_(it::date('datetime', 10), it::date('datetime', "10"), 'numeric and string give same result'); +is_(it::date('datetime', 10.0), it::date('datetime', "10"), '... as long as num is properly truncated'); +is_(it::date('datetime', 10.5), it::date('datetime', "10"), '... with one digit after point'); +is_(it::date('datetime', 10.56), it::date('datetime', "10"), '... with two digits after point'); +is_(it::date('datetime', 1000000), it::date('datetime', "1000000"), '... large nummer'); +is_(it::date('datetime', 1000000.543), it::date('datetime', "1000000"), '... large nummer and point'); +is_(it::date('time', "10.5"), "10:05", 'interpret string with points with strtotime'); +is_(it::date('time', "10.05"), "10:05", 'interpret string with points with strtotime'); +is_(it::date('Y-m-d', "20000101"), '2000-01-01', 'interpret 8 digit strings as dates'); +is_(it::date('Y-m-d', 20000101), '2000-01-01', 'interpret 8 numbers strings as dates'); +is_(it::date('Y-m-d', "20990101"), '2099-01-01', 'interpret 8 digit strings as dates'); +is_(it::date('Y-m-d', strtotime("1980-01-01")), '1980-01-01', 'interpret typical time stamps correctly'); # it::uc* -is(it::ucfirst('foo bär über'), 'Foo bär über'); -is(it::ucwords('foo bär über'), 'Foo Bär Über'); +is_(it::ucfirst('foo bär über'), 'Foo bär über'); +is_(it::ucwords('foo bär über'), 'Foo Bär Über'); # it::substr_replace -is(it::substr_replace('abcdefgh', 'xyz', 2, 4), substr_replace('abcdefgh', 'xyz', 2, 4), 'it::substr_replace the same as substr_replace for ascii'); -is(it::substr_replace('✔☯♥', '☃☃', 1, 1), '✔☃☃♥', 'it::substr_replace for utf-8'); -is(it::substr_replace('', 'xyz', 0, 0), substr_replace('', 'xyz', 0, 0), 'it::substr_replace with empty haystack the same as substr_replace'); -is(it::substr_replace('abc', 'xyz', 0, 2), substr_replace('abc', 'xyz', 0, 2), 'it::substr_replace replacing to end of haystack'); -is(it::substr_replace('abc', 'xyz', 0, 10), substr_replace('abc', 'xyz', 0, 10), 'it::substr_replace replacing past end of haystack'); -is(it::substr_replace('abcdefgh', 'xyz', 10, 4), substr_replace('abcdefgh', 'xyz', 10, 4), 'it::substr_replace outside of string'); - -is(it::any2utf8('Meier'), 'Meier', "it::any2utf8 ascii input"); -is(it::any2utf8('Müller'), 'Müller', "it::any2utf8 utf8 input"); -is(it::any2utf8('Aslı'), 'Aslı', "it::any2utf8 utf8 non-latin1 input"); -is(it::any2utf8(it::utf8_decode('Müller')), 'Müller', "it::any2utf8 latin1 input"); - -is(it::any2utf8( +is_(it::substr_replace('abcdefgh', 'xyz', 2, 4), substr_replace('abcdefgh', 'xyz', 2, 4), 'it::substr_replace the same as substr_replace for ascii'); +is_(it::substr_replace('✔☯♥', '☃☃', 1, 1), '✔☃☃♥', 'it::substr_replace for utf-8'); +is_(it::substr_replace('', 'xyz', 0, 0), substr_replace('', 'xyz', 0, 0), 'it::substr_replace with empty haystack the same as substr_replace'); +is_(it::substr_replace('abc', 'xyz', 0, 2), substr_replace('abc', 'xyz', 0, 2), 'it::substr_replace replacing to end of haystack'); +is_(it::substr_replace('abc', 'xyz', 0, 10), substr_replace('abc', 'xyz', 0, 10), 'it::substr_replace replacing past end of haystack'); +is_(it::substr_replace('abcdefgh', 'xyz', 10, 4), substr_replace('abcdefgh', 'xyz', 10, 4), 'it::substr_replace outside of string'); + +is_(it::any2utf8('Meier'), 'Meier', "it::any2utf8 ascii input"); +is_(it::any2utf8('Müller'), 'Müller', "it::any2utf8 utf8 input"); +is_(it::any2utf8('Aslı'), 'Aslı', "it::any2utf8 utf8 non-latin1 input"); +is_(it::any2utf8(it::utf8_decode('Müller')), 'Müller', "it::any2utf8 latin1 input"); + +is_(it::any2utf8( ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'), # omit soft hyphen cause we filter it ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ', "it::any2utf8 utf8 input (exhaustive alphabet)"); -is(it::any2utf8( +is_(it::any2utf8( it::utf8_decode(' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ')), ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ', "it::any2utf8 latin1 input (exhaustive alphabet)"); -is(it::any2utf8(it::utf8_encode("ü")), "ü", "it::any2utf8 double encoding"); +is_(it::any2utf8(it::utf8_encode("ü")), "ü", "it::any2utf8 double encoding"); -is(it::any2utf8("Meier"), "Meier", "it::any2utf8 ascii"); -is(it::any2utf8("Müller"), "Müller", "it::any2utf8 utf-8 latin1"); -is(it::any2utf8("Aslı"), "Aslı", "it::any2utf8 utf-8 non-latin1"); -is(it::any2utf8("é»"), "é»", "it::any2utf8 utf-8 latin1 special combination"); -is(it::any2utf8(it::utf8_encode("Müller")), "Müller", "it::any2utf8 doubly encoded utf8"); -is(it::any2utf8(it::utf8_encode(it::utf8_encode("Müller"))), "Müller", "it::any2utf8 triply encoded utf8"); -is(it::any2utf8(it::utf8_decode("Müller")), "Müller", "it::any2utf8 incorrectly encoded latin1"); -is(it::any2utf8("a💚b"), "a💚b", "it::any2utf8 correctly handles 4-byte utf-8 character GREEN HEART"); +is_(it::any2utf8("Meier"), "Meier", "it::any2utf8 ascii"); +is_(it::any2utf8("Müller"), "Müller", "it::any2utf8 utf-8 latin1"); +is_(it::any2utf8("Aslı"), "Aslı", "it::any2utf8 utf-8 non-latin1"); +is_(it::any2utf8("é»"), "é»", "it::any2utf8 utf-8 latin1 special combination"); +is_(it::any2utf8(it::utf8_encode("Müller")), "Müller", "it::any2utf8 doubly encoded utf8"); +is_(it::any2utf8(it::utf8_encode(it::utf8_encode("Müller"))), "Müller", "it::any2utf8 triply encoded utf8"); +is_(it::any2utf8(it::utf8_decode("Müller")), "Müller", "it::any2utf8 incorrectly encoded latin1"); +is_(it::any2utf8("a💚b"), "a💚b", "it::any2utf8 correctly handles 4-byte utf-8 character GREEN HEART"); -is(it::any2utf8(["foo", it::utf8_decode("bär")]), ["foo", "bär"], "any2utf8 on arrays"); -is(it::any2utf8(["foo", [it::utf8_decode("bär")]]), ["foo", ["bär"]], "any2utf8 on recursive arrays"); -is(it::any2utf8([1, true, false, null]), [1, true, false, null], "any2utf8 should leave types alone"); -is(it::any2utf8([it::utf8_decode('Müller') => it::utf8_decode('Müller')]), ['Müller' => 'Müller'], "it::any2utf8 latin1 keys"); +is_(it::any2utf8(["foo", it::utf8_decode("bär")]), ["foo", "bär"], "any2utf8 on arrays"); +is_(it::any2utf8(["foo", [it::utf8_decode("bär")]]), ["foo", ["bär"]], "any2utf8 on recursive arrays"); +is_(it::any2utf8([1, true, false, null]), [1, true, false, null], "any2utf8 should leave types alone"); +is_(it::any2utf8([it::utf8_decode('Müller') => it::utf8_decode('Müller')]), ['Müller' => 'Müller'], "it::any2utf8 latin1 keys"); -is(it::any2utf8("\xc2\xad"), "", "it::any2utf8 remove soft hyphens"); +is_(it::any2utf8("\xc2\xad"), "", "it::any2utf8 remove soft hyphens"); foreach ([ 'a' => 'ä', 'e' => 'ë', 'i' => 'ï', 'o' => 'ö', 'u' => 'ü' ] as $src => $dst) { - is(it::any2utf8("$src\xcc\x88"), $dst, "it::any2utf8 normalize combining diaeresis $dst to umlaut code $dst"); + is_(it::any2utf8("$src\xcc\x88"), $dst, "it::any2utf8 normalize combining diaeresis $dst to umlaut code $dst"); $src = mb_strtoupper($src); $dst = mb_strtoupper($dst); - is(it::any2utf8("$src\xcc\x88"), $dst, "it::any2utf8 normalize combining diaeresis $dst to umlaut code $dst"); + is_(it::any2utf8("$src\xcc\x88"), $dst, "it::any2utf8 normalize combining diaeresis $dst to umlaut code $dst"); } -is(it::any2utf8("\x65\xcc\x81"), "é", "it::any2utf8 convert to normal form C"); -is(it::any2utf8("\u{0338}\u{0338}a\u{0338}b \u{0338}\u{0338}c"), "a\u{0338}b c", "it::any2utf8 remove combining chars at start and after blank"); +is_(it::any2utf8("\x65\xcc\x81"), "é", "it::any2utf8 convert to normal form C"); +is_(it::any2utf8("\u{0338}\u{0338}a\u{0338}b \u{0338}\u{0338}c"), "a\u{0338}b c", "it::any2utf8 remove combining chars at start and after blank"); foreach ([$dummy, false, true, null, 1, "a", "Ä", "/", []] as $var) - is(it::json_decode(it::json_encode($var)), $var); -is(it::json_decode('{"foo":"bar"}')->foo, "bar"); -is(it::json_decode('{"foo":"bar"}', ['assoc' => true])['foo'], "bar"); -is(it::json_decode("\nnull\n\n", ['it_error' => ['fatal' => true]]), null, 'json_decode pretty printed null value'); + is_(it::json_decode(it::json_encode($var)), $var); +is_(it::json_decode('{"foo":"bar"}')->foo, "bar"); +is_(it::json_decode('{"foo":"bar"}', ['assoc' => true])['foo'], "bar"); +is_(it::json_decode("\nnull\n\n", ['it_error' => ['fatal' => true]]), null, 'json_decode pretty printed null value'); -is(it::cdist(null), true); -is(it::cdist(), true); +is_(it::cdist(null), true); +is_(it::cdist(), true); errlike(function() {it::cdist(false);}, "invalid file name"); errlike(function() {it::cdist("foo", false, "bar");}, "invalid file name"); -is(it::sort(["2!","19!","1!"]), ["1!", "19!", "2!"]); -is(it::sort(["2!","19!","1!"], "r"), ["2!", "19!", "1!"]); -is(it::sort(["2!","19!","1!"], "rn"), ["19!", "2!", "1!"]); -is(it::sort(["ccc", "b", "aa"], "", function ($a, $b) { return strlen($a) <=> strlen($b); }), ["b", "aa", "ccc"]); -is(it::sort(["ccc", "b", "aa"], function ($a, $b) { return strlen($a) <=> strlen($b); }), ["b", "aa", "ccc"]); -is(it::sort(["ccc", "b", "aa"], "a", function ($a, $b) { return strlen($a) <=> strlen($b); }), [1 => "b", 2 => "aa", 0 => "ccc"]); -is(it::sort(["ccc" => 2, "b" => 3, "aa" => 1], "k", function ($a, $b) { return strlen($a) <=> strlen($b); }), ['b' => 3, 'aa' => 1, 'ccc' => 2]); -is(it::sort(["ccc", "b", "aa"], "strlen"), ["b", "aa", "ccc"]); - -is(it::mod(-9, 4), 3); -is(it::mod(-8, 4), 0); -is(it::mod(0, 4), 0); -is(it::mod(7, 4), 3); - -is(it::map('5*$k+$v', [0 => 1, 1 => 2]), [1, 7]); -is(it::map(function($k, $v) {return 5*$k+$v;}, [0 => 1, 1 => 2]), [1, 7]); -is(it::map(function($v) {return 2*$v;}, [0 => 1, 1 => 2]), [2, 4]); -is(it::map('strlen', ["aaa", "aa"]), [3, 2]); -is(it::map('it::ucfirst', ["aaa"]), ["Aaa"]); +is_(it::sort(["2!","19!","1!"]), ["1!", "19!", "2!"]); +is_(it::sort(["2!","19!","1!"], "r"), ["2!", "19!", "1!"]); +is_(it::sort(["2!","19!","1!"], "rn"), ["19!", "2!", "1!"]); +is_(it::sort(["ccc", "b", "aa"], "", function ($a, $b) { return strlen($a) <=> strlen($b); }), ["b", "aa", "ccc"]); +is_(it::sort(["ccc", "b", "aa"], function ($a, $b) { return strlen($a) <=> strlen($b); }), ["b", "aa", "ccc"]); +is_(it::sort(["ccc", "b", "aa"], "a", function ($a, $b) { return strlen($a) <=> strlen($b); }), [1 => "b", 2 => "aa", 0 => "ccc"]); +is_(it::sort(["ccc" => 2, "b" => 3, "aa" => 1], "k", function ($a, $b) { return strlen($a) <=> strlen($b); }), ['b' => 3, 'aa' => 1, 'ccc' => 2]); +is_(it::sort(["ccc", "b", "aa"], "strlen"), ["b", "aa", "ccc"]); + +is_(it::mod(-9, 4), 3); +is_(it::mod(-8, 4), 0); +is_(it::mod(0, 4), 0); +is_(it::mod(7, 4), 3); + +is_(it::map('5*$k+$v', [0 => 1, 1 => 2]), [1, 7]); +is_(it::map(function($k, $v) {return 5*$k+$v;}, [0 => 1, 1 => 2]), [1, 7]); +is_(it::map(function($v) {return 2*$v;}, [0 => 1, 1 => 2]), [2, 4]); +is_(it::map('strlen', ["aaa", "aa"]), [3, 2]); +is_(it::map('it::ucfirst', ["aaa"]), ["Aaa"]); $dom = new DOMDocument; $dom->loadXML('42'); -is(it::map('$v->C14N()', $dom->childNodes), [ '42' ], "Traversable: Needs copy, not modifiable in-place"); +is_(it::map('$v->C14N()', $dom->childNodes), [ '42' ], "Traversable: Needs copy, not modifiable in-place"); # Generator function function _generator() { foreach (range(1,2) as $v) yield $v; } -is(it::map('2*$v', _generator()), [2, 4], "Generator"); +is_(it::map('2*$v', _generator()), [2, 4], "Generator"); # Special values which are not callable -is(it::map('null', ["aaa", "aa"]), [null, null]); -is(it::map('1', ["aaa", "aa"]), [1, 1]); -is(it::map(42, ["aaa", "aa"]), [42, 42]); +is_(it::map('null', ["aaa", "aa"]), [null, null]); +is_(it::map('1', ["aaa", "aa"]), [1, 1]); +is_(it::map(42, ["aaa", "aa"]), [42, 42]); # Only map selected keys -is(it::map('2*$v', [3, 4, 5], ['keys' => '0,1']), [6, 8, 5]); -is(it::map('2*$v', [3, 4, 5], ['keys' => [0,1]]), [6, 8, 5]); -is(it::map('2*$v', ['foo' => 1, 'bar' => 2], ['keys' => 'foo']), ['foo' => 2, 'bar' => 2]); +is_(it::map('2*$v', [3, 4, 5], ['keys' => '0,1']), [6, 8, 5]); +is_(it::map('2*$v', [3, 4, 5], ['keys' => [0,1]]), [6, 8, 5]); +is_(it::map('2*$v', ['foo' => 1, 'bar' => 2], ['keys' => 'foo']), ['foo' => 2, 'bar' => 2]); # it::filter -is(it::filter('$v > 2', [1, 5 => 2, 2 => 3]), [2 => 3]); -is(it::filter('$k > 2', [1, 5 => 2, 2 => 3]), [5 => 2]); -is(it::filter(function($v) {return $v > 2;}, [1, 5 => 2, 2 => 3]), [2 => 3]); -is(it::filter(function($k, $v) {return $k > 2;}, [1, 5 => 2, 2 => 3]), [5 => 2]); - -is(it::split("b", "aba"), ["a", "a"]); -is(it::split("b", "aBa"), ["a", "a"]); -is(it::split("b", "abba"), ["a", "", "a"]); -is(it::split("b", "ababa", ['limit' => 2]), ["a", "aba"]); -is(it::split("b", "abbba", ['no_empty' => true]), ["a", "a"]); -is(it::split("(b)", "aba", ['delim_capture' => true]), ["a", "b", "a"]); -is(it::split("b", "aabaa", ['offset_capture' => true]), [["aa", 0], ["aa", 3]]); +is_(it::filter('$v > 2', [1, 5 => 2, 2 => 3]), [2 => 3]); +is_(it::filter('$k > 2', [1, 5 => 2, 2 => 3]), [5 => 2]); +is_(it::filter(function($v) {return $v > 2;}, [1, 5 => 2, 2 => 3]), [2 => 3]); +is_(it::filter(function($k, $v) {return $k > 2;}, [1, 5 => 2, 2 => 3]), [5 => 2]); + +is_(it::split("b", "aba"), ["a", "a"]); +is_(it::split("b", "aBa"), ["a", "a"]); +is_(it::split("b", "abba"), ["a", "", "a"]); +is_(it::split("b", "ababa", ['limit' => 2]), ["a", "aba"]); +is_(it::split("b", "abbba", ['no_empty' => true]), ["a", "a"]); +is_(it::split("(b)", "aba", ['delim_capture' => true]), ["a", "b", "a"]); +is_(it::split("b", "aabaa", ['offset_capture' => true]), [["aa", 0], ["aa", 3]]); $tmpfile = tempnam("/tmp", "it_test"); it::file_put_contents($tmpfile, "abc"); -is(($fh = it::fopen($tmpfile, "r")) ? fgets($fh) : null, "abc"); -is(it::file_get_contents($tmpfile), "abc"); -is(it::file_get_contents($tmpfile, false, null, 1), "bc"); -is(it::file_get_contents($tmpfile, false, null, 0, 2), "ab"); -is(it::file_get_contents($tmpfile, false, null, 1, 1), "b"); -is(it::file($tmpfile), ["abc"]); +is_(($fh = it::fopen($tmpfile, "r")) ? fgets($fh) : null, "abc"); +is_(it::file_get_contents($tmpfile), "abc"); +is_(it::file_get_contents($tmpfile, false, null, 1), "bc"); +is_(it::file_get_contents($tmpfile, false, null, 0, 2), "ab"); +is_(it::file_get_contents($tmpfile, false, null, 1, 1), "b"); +is_(it::file($tmpfile), ["abc"]); ob_start(); it::readfile($tmpfile); -is(ob_get_clean(), "abc"); +is_(ob_get_clean(), "abc"); it::file_put($tmpfile, "bb"); -is(it::file_get($tmpfile), "bb"); +is_(it::file_get($tmpfile), "bb"); unlink($tmpfile); requesturi(it::utf8_decode("lüönd"), "lüönd"); @@ -565,7 +565,7 @@ function requesturi($teststring, $expect) { $_SERVER['REQUEST_URI'] = urlencode($teststring); it::params2utf8(); - is(urldecode($_SERVER['REQUEST_URI']), $expect, "parms2utf8('$expect')"); # NOPHPLINT + is_(urldecode($_SERVER['REQUEST_URI']), $expect, "parms2utf8('$expect')"); # NOPHPLINT } _getopt(["val"], ['foo' => "val"]); @@ -592,8 +592,8 @@ function _getopt($in, $expect) -b, --brg=ARG Have another arg "); - is($opts, ['args' => $expect['args'] ?? []] + $expect); + is_($opts, ['args' => $expect['args'] ?? []] + $expect); } -is(it::urldecode("a%61%E4"), "aaä"); -is(it::parse_str("%E4[%E4][%E4]=%E4"), ['ä' => ['ä' => ['ä' => 'ä']]]); +is_(it::urldecode("a%61%E4"), "aaä"); +is_(it::parse_str("%E4[%E4][%E4]=%E4"), ['ä' => ['ä' => ['ä' => 'ä']]]); diff --git a/test/it_cache.t b/test/it_cache.t index 3e2fb0d..10f639d 100755 --- a/test/it_cache.t +++ b/test/it_cache.t @@ -3,29 +3,29 @@ # test array_based process cache it_cache::put('it_cache_t', 42); -is(it_cache::get('it_cache_t'), 42, "cache put number"); +is_(it_cache::get('it_cache_t'), 42, "cache put number"); it_cache::put('it_cache_t', false); -is(it_cache::get('it_cache_t'), false, "cache get number"); +is_(it_cache::get('it_cache_t'), false, "cache get number"); it_cache::put('it_cache_t', [2]); -is(it_cache::get('it_cache_t'), [2], "cache put/get array"); +is_(it_cache::get('it_cache_t'), [2], "cache put/get array"); # test non-distributed apc cache it_cache::put('it_cache_t', 42); it_cache::$_local = []; -is(it_cache::get('it_cache_t'), 42, "local put/get number"); +is_(it_cache::get('it_cache_t'), 42, "local put/get number"); it_cache::put('it_cache_t', false); it_cache::$_local = []; -is(it_cache::get('it_cache_t'), false, "local put/get false"); +is_(it_cache::get('it_cache_t'), false, "local put/get false"); it_cache::put('it_cache_t', [2]); it_cache::$_local = []; -is(it_cache::get('it_cache_t'), [2], "local put/get array"); +is_(it_cache::get('it_cache_t'), [2], "local put/get array"); -is(it_cache::get('it_cache_t'.rand(1, 1000)), null, "local get unknown key"); +is_(it_cache::get('it_cache_t'.rand(1, 1000)), null, "local get unknown key"); # test distributed memcache @@ -34,16 +34,16 @@ $GLOBALS['debug_aslive'] = 1; it_cache::put('it_cache_d', 42, ['distributed' => 1]); it_cache::put('it_cache_d', 1); it_cache::$_local = []; -is(intval(it_cache::get('it_cache_d', ['distributed' => 1])), 42, "distributed put/get number"); +is_(intval(it_cache::get('it_cache_d', ['distributed' => 1])), 42, "distributed put/get number"); it_cache::put('it_cache_d', false, ['distributed' => 1]); it_cache::put('it_cache_d', 2); it_cache::$_local = []; -is(boolval(it_cache::get('it_cache_d', ['distributed' => 1])), false, "distributed put/get false"); +is_(boolval(it_cache::get('it_cache_d', ['distributed' => 1])), false, "distributed put/get false"); it_cache::put('it_cache_d', [2], ['distributed' => 1]); it_cache::put('it_cache_d', 3); it_cache::$_local = []; -is(it_cache::get('it_cache_d', ['distributed' => 1]), [2], "distributed put/get array"); +is_(it_cache::get('it_cache_d', ['distributed' => 1]), [2], "distributed put/get array"); -is(it_cache::get('it_cache_d'.rand(1, 1000), ['distributed' => 1]), null, "distributed get unknown key"); +is_(it_cache::get('it_cache_d'.rand(1, 1000), ['distributed' => 1]), null, "distributed get unknown key"); diff --git a/test/it_dbi.t b/test/it_dbi.t index 1140c55..8a4f82d 100755 --- a/test/it_dbi.t +++ b/test/it_dbi.t @@ -38,18 +38,18 @@ $opts['subclass']::createclass(['table' => "it_dbi_test", 'forcecreate' => true] $record = new it_dbi_test; $GLOBALS['it_defaultconfig']['fatal_throws_exception'] = true; -is(@$record->query("SYNTAX ERROR", ['safety' => 0]), false, "Suppress failures with safety 0"); +is_(@$record->query("SYNTAX ERROR", ['safety' => 0]), false, "Suppress failures with safety 0"); try { - is(@$record->select("SYNTAX ERROR"), "Exception", "Syntax triggers exception for fatal_throws_exception mode"); + is_(@$record->select("SYNTAX ERROR"), "Exception", "Syntax triggers exception for fatal_throws_exception mode"); } catch (Exception $e) { - is(it::match('syntax', $e->getMessage()), 'syntax', "Syntax error triggers error"); + is_(it::match('syntax', $e->getMessage()), 'syntax', "Syntax error triggers error"); } $record->insert(['x' => 42, 'y' => 0.0001, 'z' => 0, 'foo' => null, 'flag' => 1]); $record->insert(['foo' => "bar", 'y' => 1e-10, 'z' => 0, 'flag' => 0]); $record->insert(['x' => 64738, 'y' => 1, 'z' => 0, 'foo' => "q'uux"]); -is( +is_( $record->ID, 3, "auto_increment" @@ -58,11 +58,11 @@ is( try { @$record->insert(['ID' => 3]); } catch (Exception $e) { - is($e->getMessage(), false, "Silently ignore duplicate inserts with default safety"); + is_($e->getMessage(), false, "Silently ignore duplicate inserts with default safety"); } $record->read(1); -is( +is_( [$record->_key, $record->x, $record->y, $record->foo], [1, 42, 0.0001, null], "read" @@ -71,132 +71,132 @@ ok(!!$record->flag, "read true boolean"); $record->read(2); ok(!$record->flag, "read false boolean"); -is( +is_( $record->select(), 3, "select without parameters select all" ); -is( +is_( @$record->select(['foo <>' => ""], "LIMIT 1"), 1, "select with multiple parameters (LIMIT part)" ); -is( +is_( $record->foo, "bar", "select with multiple parameters (foo part)" ); -is( +is_( $record->select(['ID IN' => [2,3]]), 2, "select with IN" ); -is( +is_( $record->select(['ID NI' => [2,3]]), 2, "select with NI" ); -is( +is_( $record->select(['ID NOT IN' => [2,3]]), 1, "select with NOT IN" ); -is( +is_( $record->select(['ID IN' => []]), 0, "select with empty IN" ); -is( +is_( $record->select(['ID NOT IN' => []]), 3, "select with empty NOT IN" ); -is( +is_( $record->select(['ID' => [2,3]]), 2, "select with implicit IN" ); $record = new it_dbi_test; -is( +is_( $record->x, null, "constructor of created class without argument" ); $record = new it_dbi_test(2); -is( +is_( $record->ID, 2, "constructor of created class with id parameter" ); $record = new it_dbi_test(['x >' => 0], "ORDER BY x DESC"); -is( +is_( $record->x, 64738, "constructor of created class with multiple select parameters" ); $record = new it_dbi_test(['foo' => 'bar']); -is( +is_( $record->ID, 2, "constructor of created class with single array parameter" ); $record = new it_dbi_test; -is( +is_( $record->x, null, "constructor without parameters" ); $record = new it_dbi_test(['x >' => 0], "ORDER BY x DESC"); -is( +is_( $record->x, 64738, "constructor with multiple select parameters" ); $record->select(['x' => 64738]); -is( +is_( [$record->_key, $record->x, $record->foo], [3, 64738, "q'uux"], "select" ); $record->update(['x' => 17]); -is( +is_( [$record->_key, $record->x, $record->foo], [3, 17, "q'uux"], "update" ); $record->update(['flag' => "astring"]); -is($record->flag, 0, "use non-numeric string to set tinyint flag"); +is_($record->flag, 0, "use non-numeric string to set tinyint flag"); $record->update(['flag' => true]); -is($record->flag, 1, "use boolean true to set tinyint flag"); +is_($record->flag, 1, "use boolean true to set tinyint flag"); $record->update(['flag' => false]); -is($record->flag, 0, "use boolean false to set tinyint flag"); +is_($record->flag, 0, "use boolean false to set tinyint flag"); -is( +is_( $record->update(['x' => 18], ['x' => 17]), 1, "return affected rows" ); -is( +is_( $record->update(['x' => 18], ['x' => 17]), 0, "return zero affected rows" ); $record->update(['-x' => 'POW(2,2) * 10']); -is( +is_( [$record->_key, $record->x, $record->foo], [3, 40, "q'uux"], "update with function" @@ -204,23 +204,23 @@ is( $value = pow(2, 24) + 1; $record->update(['x' => $value]); -is($record->x, $value, "update 32bit integer without float representation"); -is($record->select(['x' => $value]), 1, "select 32bit integer without float representation"); +is_($record->x, $value, "update 32bit integer without float representation"); +is_($record->select(['x' => $value]), 1, "select 32bit integer without float representation"); $value = pow(2, 53) + 1; $record->update(['z' => $value]); -is($record->z, "$value", "update 64bit integer without double representation"); -is($record->select(['z' => $value]), 1, "select 64bit integer without double representation"); +is_($record->z, "$value", "update 64bit integer without double representation"); +is_($record->select(['z' => $value]), 1, "select 64bit integer without double representation"); $record->update(['foo' => "10", 'x' => 10]); -is($record->select(['x <' => 9]), 0, "always use integer comparision for int field"); -is($record->select(['x <' => '9']), 0, "always use integer comparision for int field"); -is($record->select(['foo <' => 9]), 1, "always use string comparision for varchar field"); -is($record->select(['foo <' => '9']), 1, "always use string comparision for varchar field"); +is_($record->select(['x <' => 9]), 0, "always use integer comparision for int field"); +is_($record->select(['x <' => '9']), 0, "always use integer comparision for int field"); +is_($record->select(['foo <' => 9]), 1, "always use string comparision for varchar field"); +is_($record->select(['foo <' => '9']), 1, "always use string comparision for varchar field"); $record->update(['foo' => "00"]); $rand = $record->x; -is ( +is_( $record->_set(['x' => $rand, 'foo' => "0"]), $record->_set(['foo' => "0"]), 'update: _set optimization' @@ -236,14 +236,14 @@ ok(!$record->_set(['foo' => NULL]), 'update: _set optimization no update NULL => $record->update(['foo' => "bar"]); $record->select(['foo' => "bar"]); $record->iterate(); -is( +is_( [$record->_key, $record->x, $record->foo], [2, null, "bar"], "iterate record 2" ); $record->update(['foo' => "qux"]); $record->iterate(); -is( +is_( [$record->_key, $record->x, $record->foo], [3, $rand, "bar"], "iterate record 3" @@ -251,20 +251,20 @@ is( $record->update(['foo' => "quux"]); $record->read(2); -is( +is_( [$record->_key, isset($record->x), $record->foo], [2, false, "qux"], "iterate update record 2" ); $record->read(3); -is( +is_( [$record->_key, $record->x, $record->foo], [3, $rand, "quux"], "iterate update record 3" ); -is( +is_( gettype($record->_key) . "/" . gettype($record->x) . "/" . gettype($record->_data['x']) . "/" . gettype($record->foo), "integer/integer/integer/string", "automatic type detection" @@ -274,30 +274,30 @@ $count = 0; foreach (new it_dbi_test as $id => $record) { $count++; - is($record->_key, $id, "Iterator id $id"); + is_($record->_key, $id, "Iterator id $id"); } -is($count, 3, "Iterator without select"); +is_($count, 3, "Iterator without select"); $count = 0; foreach (new $opts['subclass']($db + ['table' => 'it_dbi_test']) as $id => $record) { $count++; - is($record->_key, $id, "Iterator id $id (it_dbi object)"); + is_($record->_key, $id, "Iterator id $id (it_dbi object)"); } -is($count, 3, "Iterator without select (it_dbi_object)"); +is_($count, 3, "Iterator without select (it_dbi_object)"); $count = 0; foreach (new it_dbi_test(['foo <>' => ""]) as $id => $record) { $count++; - is($record->_key, $id, "Iterator id $id"); + is_($record->_key, $id, "Iterator id $id"); } -is($count, 2, "Iterator with select"); +is_($count, 2, "Iterator with select"); $count = 0; foreach ($record as $dummy_rec) $count++; -is($count, 2, "Iterator reused"); +is_($count, 2, "Iterator reused"); $GLOBALS['debug_sqllog'] = true; @$record->store(['ID' => 5, 'x' => 6]); @@ -308,7 +308,7 @@ like( ); $record->clear(); @$record->read(5); -is( +is_( $record->x, 6, "saving with store" @@ -323,7 +323,7 @@ like( ); $record->clear(); @$record->read(5); -is( +is_( $record->x, 7, "updating with store" @@ -331,7 +331,7 @@ is( $record->_sqllog = []; @$record->store(['ID' => 5, 'x' => 7]); -is( +is_( $record->_sqllog[1]['query'], null, # Only SELECT, no UPDATE "Optimized away UPDATE with same values" @@ -361,13 +361,13 @@ $record->insert(['foobar_de' => "deutsch2", 'foobar_fr' => "franz2"]); T_set_language('de'); $record->select([]); $record->iterate(); -is( +is_( [$record->_key, $record->foobar], [1, "deutsch"], "localized field foobar_de" ); $record->iterate(); -is( +is_( [$record->_key, $record->foobar], [2, "deutsch2"], "localized field foobar_de iterate" @@ -375,7 +375,7 @@ is( T_set_language('fr'); $record->read(1); -is( +is_( [$record->_key, $record->foobar], [1, "franz"], "localized field foobar_fr" @@ -387,42 +387,42 @@ is( # REPLACE (without and with quoting) $r = new it_dbi_test; -$r->replace(['ID' => 5, '-key1' => "2*2"]); is($r->key1, 4); -$r->replace(['ID' => 5, 'key1' => 42]); is($r->key1, 42, "Preserve type int on dyncols insert"); -$r->update(['key1' => 43]); is($r->key1, 43, "Preserve type int on dyncols update"); -$r->replace(['ID' => 5, 'key1' => "val0'"]); is($r->key1, "val0'"); +$r->replace(['ID' => 5, '-key1' => "2*2"]); is_($r->key1, 4); +$r->replace(['ID' => 5, 'key1' => 42]); is_($r->key1, 42, "Preserve type int on dyncols insert"); +$r->update(['key1' => 43]); is_($r->key1, 43, "Preserve type int on dyncols update"); +$r->replace(['ID' => 5, 'key1' => "val0'"]); is_($r->key1, "val0'"); # UPDATE with WHERE (without and with quoting) -$r->update(['-key1' => "2*2"], ['key1' => "val0'"]); is($r->key1, 4); -$r->update(['key1' => "val1'"], ['key1' => "4"]); is($r->key1, "val1'"); +$r->update(['-key1' => "2*2"], ['key1' => "val0'"]); is_($r->key1, 4); +$r->update(['key1' => "val1'"], ['key1' => "4"]); is_($r->key1, "val1'"); # UPDATE (without and with quoting) -$r->update(['key1' => "val1'", 'key2' => "ö"]); is($r->key1, "val1'"); is($r->key2, "ö"); # check mariadb bug -$r->update(['-key2' => "1*2"]); is($r->key1, "val1'"); is($r->key2, 2); -$r->update(['key2' => "val2\""]); is($r->key1, "val1'"); is($r->key2, "val2\""); -$r->update(['-key3' => "1*3"]); is($r->key1, "val1'"); is($r->key2, "val2\""); is($r->key3, 3); -$r->update(['key1' => "val0'"]); is($r->key1, "val0'"); is($r->key2, "val2\""); is($r->key3, 3); -$r->update(['key1' => "val/'"]); is($r->key1, "val/'"); # check json encoding +$r->update(['key1' => "val1'", 'key2' => "ö"]); is_($r->key1, "val1'"); is_($r->key2, "ö"); # check mariadb bug +$r->update(['-key2' => "1*2"]); is_($r->key1, "val1'"); is_($r->key2, 2); +$r->update(['key2' => "val2\""]); is_($r->key1, "val1'"); is_($r->key2, "val2\""); +$r->update(['-key3' => "1*3"]); is_($r->key1, "val1'"); is_($r->key2, "val2\""); is_($r->key3, 3); +$r->update(['key1' => "val0'"]); is_($r->key1, "val0'"); is_($r->key2, "val2\""); is_($r->key3, 3); +$r->update(['key1' => "val/'"]); is_($r->key1, "val/'"); # check json encoding # Check for mistakenly inherited fields -$r->replace(['ID' => 6, 'key4' => "val4'"]); is($r->key4, "val4'"); -$r->select(['key2' => "val2\""]); is($r->key2, "val2\""); is($r->key4, null, "cleared previous fields?"); +$r->replace(['ID' => 6, 'key4' => "val4'"]); is_($r->key4, "val4'"); +$r->select(['key2' => "val2\""]); is_($r->key2, "val2\""); is_($r->key4, null, "cleared previous fields?"); # Check removal of unnecessary writes $r->_writes = 0; $r->select(['ID' => 6]); -$r->update(['key4' => "val4'"]); is($r->_writes, 0); is($r->key4, "val4'"); -$r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r->key4, "val4'"); is($r->key5, "val5'"); -$r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r->key4, "val4'"); is($r->key5, "val5'"); +$r->update(['key4' => "val4'"]); is_($r->_writes, 0); is_($r->key4, "val4'"); +$r->update(['key4' => "val4'", 'key5' => "val5'"]); is_($r->_writes, 1); is_($r->key4, "val4'"); is_($r->key5, "val5'"); +$r->update(['key4' => "val4'", 'key5' => "val5'"]); is_($r->_writes, 1); is_($r->key4, "val4'"); is_($r->key5, "val5'"); # Check LIMIT $count = $r->select(['ID >' => 0, "ORDER BY $primarykey DESC", 'LIMIT' => 1]); -is($count, 1, "Simple LIMIT: count"); -is($r->ID, 6, "Simple LIMIT: id"); +is_($count, 1, "Simple LIMIT: count"); +is_($r->ID, 6, "Simple LIMIT: id"); $count = $r->select(['ID >' => 0, "ORDER BY $primarykey DESC", 'LIMIT' => "1, 2"]); -is($count, 2, "LIMIT with offset: count"); -is($r->ID, 5, "LIMIT with offset: id"); -is($r->select(['ID >' => 0, "ORDER BY $primarykey DESC", 'LIMIT' => false]), 5, "no limit"); +is_($count, 2, "LIMIT with offset: count"); +is_($r->ID, 5, "LIMIT with offset: id"); +is_($r->select(['ID >' => 0, "ORDER BY $primarykey DESC", 'LIMIT' => false]), 5, "no limit"); # Check if iterator clears dynfields left over from previous record $r->delete(["WHERE TRUE"]); @@ -432,30 +432,30 @@ $r->replace(['ID' => 3]); $r->clear(false); $r->select("WHERE TRUE ORDER BY $primarykey"); $r->iterate(); -is($r->key1, "a"); is($r->key2, null); +is_($r->key1, "a"); is_($r->key2, null); $r->iterate(); -is($r->key1, null); is($r->key2, "b"); +is_($r->key1, null); is_($r->key2, "b"); $r->iterate(); -is($r->_dyndata, [], '_dyndata for record with empty dyncols should be empty'); +is_($r->_dyndata, [], '_dyndata for record with empty dyncols should be empty'); $r->update(['key3' => 'c']); -is($r->key3, 'c', 'dynamic column for record with empty dyncols whould be correctly created'); +is_($r->key3, 'c', 'dynamic column for record with empty dyncols whould be correctly created'); $r->update(['key3' => null], ['ID' => 3]); -is($r->key3, null, 'remove dynamic column completely if where-clause is given'); +is_($r->key3, null, 'remove dynamic column completely if where-clause is given'); $r->clear(false); -is($r->select(['-key1 IS NOT' => 'NULL']), 1, 'only one entry has a value for key1'); -is($r->select(['-key1 IS' => 'NULL']), 2, "two entries don't have a value for key1"); -is($r->select(['key1' => null]), 2, "same behaviour without - syntax"); +is_($r->select(['-key1 IS NOT' => 'NULL']), 1, 'only one entry has a value for key1'); +is_($r->select(['-key1 IS' => 'NULL']), 2, "two entries don't have a value for key1"); +is_($r->select(['key1' => null]), 2, "same behaviour without - syntax"); $r->read(1); $r->update(['key1' => null]); -is($r->key1, null, 'setting dyncol to null should make it be null'); -is($r->select(['-key1 IS NOT' => 'NULL']), 0, 'no entry should have a value for key1 anymore'); +is_($r->key1, null, 'setting dyncol to null should make it be null'); +is_($r->select(['-key1 IS NOT' => 'NULL']), 0, 'no entry should have a value for key1 anymore'); # don't do dyncols stuff in where when we select form multiple tables (column names are unknown then) -is($r->_where(['FROM' => 'it_dbi_test AS a, it_dbi_test AS b', '-a.ID' => 'b.ID']), 'WHERE a.ID = b.ID', "don't do JSON_EXTRACT when we have multiple tables in FROM"); -is($r->_where(['JOIN' => 'it_dbi_test AS b', '-a.ID' => 'b.ID']), 'WHERE a.ID = b.ID', "don't do JSON_EXTRACT when we JOIN"); +is_($r->_where(['FROM' => 'it_dbi_test AS a, it_dbi_test AS b', '-a.ID' => 'b.ID']), 'WHERE a.ID = b.ID', "don't do JSON_EXTRACT when we have multiple tables in FROM"); +is_($r->_where(['JOIN' => 'it_dbi_test AS b', '-a.ID' => 'b.ID']), 'WHERE a.ID = b.ID', "don't do JSON_EXTRACT when we JOIN"); -is($r->_where(['LOWER(a)' => 'x']), "WHERE LOWER(a) = 'x'", "don't do JSON_EXTRACT when we use SQL functions"); +is_($r->_where(['LOWER(a)' => 'x']), "WHERE LOWER(a) = 'x'", "don't do JSON_EXTRACT when we use SQL functions"); # # Test tracked update @@ -472,29 +472,29 @@ $record->delete(['WHERE TRUE' ]); $record->upsert(['ID' => 1, 'foo' => "a"]); $record->upsert(['ID' => 2, 'foo' => "b"]); $record->upsert(['ID' => 2, 'foo' => "B"]); -is($record->delete_untouched(), [], 'delete_untouched'); -is(allrecs(), '[{"ID":1,"foo":"a"},{"ID":2,"foo":"B"}]', 'data after delete_untouched'); +is_($record->delete_untouched(), [], 'delete_untouched'); +is_(allrecs(), '[{"ID":1,"foo":"a"},{"ID":2,"foo":"B"}]', 'data after delete_untouched'); $record->upsert(['ID' => 1, 'foo' => "A"]); $record->upsert(['ID' => 3, 'foo' => "c"]); -is($record->delete_untouched([ 'ID >' => 2 ]), [], 'delete_untouched with query'); -is(allrecs(), '[{"ID":1,"foo":"A"},{"ID":2,"foo":"B"},{"ID":3,"foo":"c"}]', 'data after delete_untouched with query'); +is_($record->delete_untouched([ 'ID >' => 2 ]), [], 'delete_untouched with query'); +is_(allrecs(), '[{"ID":1,"foo":"A"},{"ID":2,"foo":"B"},{"ID":3,"foo":"c"}]', 'data after delete_untouched with query'); # Test it::map with it_dbi (clone vs. reference issue) -is(it::map('$v->foo', new it_dbi_test(['ID' => [1, 2, 3]])), [1 => 'A', 2 => 'B', 3 => 'c'], 'it_dbi with it::map'); -is(it::map('$v->foo', iterator_to_array(new it_dbi_test(['ID' => [1, 2, 3]]))), [1 => 'A', 2 => 'B', 3 => 'c'], 'it_dbi with iterator_to_array'); +is_(it::map('$v->foo', new it_dbi_test(['ID' => [1, 2, 3]])), [1 => 'A', 2 => 'B', 3 => 'c'], 'it_dbi with it::map'); +is_(it::map('$v->foo', iterator_to_array(new it_dbi_test(['ID' => [1, 2, 3]]))), [1 => 'A', 2 => 'B', 3 => 'c'], 'it_dbi with iterator_to_array'); $record->upsert(['ID' => 3, 'foo' => "C"]); -is(it::sort($record->delete_untouched()), [1, 2], 'delete_untouched with query'); -is(allrecs(), '[{"ID":3,"foo":"C"}]', 'data after delete_untouched with query'); +is_(it::sort($record->delete_untouched()), [1, 2], 'delete_untouched with query'); +is_(allrecs(), '[{"ID":3,"foo":"C"}]', 'data after delete_untouched with query'); $record->replace(['ID' => 4, 'foo' => "C"]); -is($record->delete_untouched(), [3], 'delete_untouched after replace'); -is(allrecs(), '[{"ID":4,"foo":"C"}]', 'data after delete_untouched after replace'); +is_($record->delete_untouched(), [3], 'delete_untouched after replace'); +is_(allrecs(), '[{"ID":4,"foo":"C"}]', 'data after delete_untouched after replace'); $record->upsert(['ID' => 4, 'foo' => "C"]); -is($record->delete_untouched(), [], 'delete_untouched after upsert without changes'); -is(allrecs(), '[{"ID":4,"foo":"C"}]', 'data after delete_untouched after upsert without changes'); +is_($record->delete_untouched(), [], 'delete_untouched after upsert without changes'); +is_(allrecs(), '[{"ID":4,"foo":"C"}]', 'data after delete_untouched after upsert without changes'); # # Test _read_postprocess and _write_preprocess @@ -524,15 +524,15 @@ $record = new my_dbi_test; $record->delete(['WHERE TRUE' ]); $record->upsert(['ID' => 1, 'x' => 42, 'y' => 2.5, 'foo' => ['value' => "a"], 'flag' => 0]); $record->read(1); -is($record->x, 42, 'value of x after reading with _read_postprocess'); -is($record->_data, ["ID" => 1, "x" => 42, 'y' => 2.5, 'z' => NULL, 'foo' => '{"value":"a"}', 'flag' => 0], 'data after reading with _read_postprocess'); -is($record->foo, ['value' => "a"], 'field after reading with _read_postprocess'); +is_($record->x, 42, 'value of x after reading with _read_postprocess'); +is_($record->_data, ["ID" => 1, "x" => 42, 'y' => 2.5, 'z' => NULL, 'foo' => '{"value":"a"}', 'flag' => 0], 'data after reading with _read_postprocess'); +is_($record->foo, ['value' => "a"], 'field after reading with _read_postprocess'); $record2 = new it_dbi_test; $record2->read(1); -is($record2->x, 43, 'raw value of x after writing with _write_preprocess'); -is($record2->_data, ["ID" => 1, "x" => 43, 'y' => 2.5, 'z' => NULL, 'foo' => '{"value":"a"}', 'flag' => 0], 'raw data after writing with _write_preprocess'); +is_($record2->x, 43, 'raw value of x after writing with _write_preprocess'); +is_($record2->_data, ["ID" => 1, "x" => 43, 'y' => 2.5, 'z' => NULL, 'foo' => '{"value":"a"}', 'flag' => 0], 'raw data after writing with _write_preprocess'); $record->update(['foo' => ['value' => "b"]]); -is($record->_data, ["ID" => 1, "x" => 42, 'y' => 2.5, 'z' => NULL, 'foo' => '{"value":"b"}', 'flag' => 0], 'raw data after updating with _write_preprocess'); -is($record->foo, ['value' => "b"], 'field data after updating with _write_preprocess'); +is_($record->_data, ["ID" => 1, "x" => 42, 'y' => 2.5, 'z' => NULL, 'foo' => '{"value":"b"}', 'flag' => 0], 'raw data after updating with _write_preprocess'); +is_($record->foo, ['value' => "b"], 'field data after updating with _write_preprocess'); diff --git a/test/it_error.t b/test/it_error.t index a45e312..f12c05c 100755