From: Ulf Wendel Date: Thu, 12 Jul 2007 20:42:48 +0000 (+0000) Subject: Next 10 in row to be tweaked: X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~154 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=202ba6c5fe6dd092c00dfcd65a9639019e402607;p=php Next 10 in row to be tweaked: - take connection parameter from connect.inc - use proper UEXPECTF - have 'print "done!"' or similar at the end to detect crashes - whitespace changes where needed - take care of portability: PHP 5 vs. PHP 5, MySQL 4.1 - 6.0 - understand return value checking as sometime that makes you type more when you write but makes you happy when you debug --- diff --git a/ext/mysqli/tests/010.phpt b/ext/mysqli/tests/010.phpt index 6b79d62f42..8f24812833 100644 --- a/ext/mysqli/tests/010.phpt +++ b/ext/mysqli/tests/010.phpt @@ -9,20 +9,23 @@ precision=12 include "connect.inc"; /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); + $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); + if (!mysqli_query($link, "SET sql_mode=''")) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 float(3), - c2 float, - c3 float unsigned, - c4 float, - c5 float, - c6 float, - c7 float(10) unsigned)"); + if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch")) + printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $rc = mysqli_query($link, "CREATE TABLE test_bind_fetch(c1 float(3), + c2 float, + c3 float unsigned, + c4 float, + c5 float, + c6 float, + c7 float(10) unsigned) ENGINE=" . $engine); + if (!$rc) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_query($link, "INSERT INTO test_bind_fetch (c1,c2,c3,c4,c5,c6,c7) VALUES (3.1415926535,-0.000001, -5, 999999999999, @@ -39,6 +42,7 @@ precision=12 mysqli_stmt_close($stmt); mysqli_close($link); + print "done!"; ?> --EXPECT-- array(7) { @@ -57,3 +61,4 @@ array(7) { [6]=> float(888888914608000) } +done! \ No newline at end of file diff --git a/ext/mysqli/tests/011.phpt b/ext/mysqli/tests/011.phpt index 7cef7292b9..e6d9492c80 100644 --- a/ext/mysqli/tests/011.phpt +++ b/ext/mysqli/tests/011.phpt @@ -9,21 +9,25 @@ precision=12 include "connect.inc"; /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); + $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); - mysqli_select_db($link, "test"); + if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result")) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"); + $rc = mysqli_query($link, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, + c3 int, c4 bigint, + c5 float, c6 double, + c7 varbinary(10), + c8 varchar(50)) ENGINE=" . $engine); + if (!$rc) + printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_query($link,"CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, - c3 int, c4 bigint, - c5 float, c6 double, - c7 varbinary(10), - c8 varchar(50))"); - - mysqli_query($link,"INSERT INTO test_bind_result VALUES(19,2999,3999,4999999, - 2345.6,5678.89563, - 'foobar','mysql rulez')"); + $rc = mysqli_query($link,"INSERT INTO test_bind_result VALUES(19,2999,3999,4999999, + 2345.6,5678.89563, + 'foobar','mysql rulez')"); + if (!$rc) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result"); mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8); mysqli_execute($stmt); @@ -35,6 +39,7 @@ precision=12 mysqli_stmt_close($stmt); mysqli_close($link); + print "done!"; ?> --EXPECTF-- array(8) { @@ -51,7 +56,28 @@ array(8) { [5]=> float(5678.89563) [6]=> - %s(6) "foobar" + string(6) "foobar" + [7]=> + string(11) "mysql rulez" +} +done! +--UEXPECTF-- +array(8) { + [0]=> + int(19) + [1]=> + int(2999) + [2]=> + int(3999) + [3]=> + int(4999999) + [4]=> + float(2345.60009766) + [5]=> + float(5678.89563) + [6]=> + string(6) "foobar" [7]=> - %s(11) "mysql rulez" + unicode(11) "mysql rulez" } +done! \ No newline at end of file diff --git a/ext/mysqli/tests/012.phpt b/ext/mysqli/tests/012.phpt index 487019cc4d..fafe2a0ee2 100644 --- a/ext/mysqli/tests/012.phpt +++ b/ext/mysqli/tests/012.phpt @@ -7,23 +7,25 @@ precision=12 --FILE-- --EXPECTF-- array(8) { @@ -52,7 +55,28 @@ array(8) { [5]=> float(58.89) [6]=> - %s(3) "206" + string(3) "206" + [7]=> + string(3) "6.7" +} +done! +--UEXPECTF-- +array(8) { + [0]=> + int(120) + [1]=> + int(2999) + [2]=> + int(3999) + [3]=> + int(54) + [4]=> + float(2.59999990463) + [5]=> + float(58.89) + [6]=> + string(3) "206" [7]=> - %s(3) "6.7" + unicode(3) "6.7" } +done! \ No newline at end of file diff --git a/ext/mysqli/tests/013.phpt b/ext/mysqli/tests/013.phpt index 60caff5b8a..a0b3b2b6a1 100644 --- a/ext/mysqli/tests/013.phpt +++ b/ext/mysqli/tests/013.phpt @@ -5,48 +5,53 @@ mysqli fetch mixed / mysql_query (may fail when using 4.1 library with 5.x serve --FILE-- 40100 && mysqli_get_client_version() < 50000 && - mysqli_get_server_version($link) > 50000) + mysqli_get_server_version($link) > 50000) echo "error (4.1 library with 5.x server)"; else echo "error"; mysqli_close($link); + print "done!"; ?> --EXPECTF-- ok +done! \ No newline at end of file diff --git a/ext/mysqli/tests/014.phpt b/ext/mysqli/tests/014.phpt index 4c746a1a6c..7d21deb6c1 100644 --- a/ext/mysqli/tests/014.phpt +++ b/ext/mysqli/tests/014.phpt @@ -1,12 +1,16 @@ --TEST-- -mysqli autocommit/commit/rollback +mysqli autocommit/commit/rollback --SKIPIF-- --EXPECTF-- Num_of_rows=1 array(2) { [0]=> - %s(1) "1" + string(1) "1" + [1]=> + string(6) "foobar" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(4) "egon" +} +done! +--UEXPECTF-- +Num_of_rows=1 +array(2) { + [0]=> + unicode(1) "1" [1]=> - %s(6) "foobar" + unicode(6) "foobar" } array(2) { [0]=> - %s(1) "2" + unicode(1) "2" [1]=> - %s(4) "egon" + unicode(4) "egon" } +done! \ No newline at end of file diff --git a/ext/mysqli/tests/015.phpt b/ext/mysqli/tests/015.phpt index f8881987bd..db0d997fa1 100644 --- a/ext/mysqli/tests/015.phpt +++ b/ext/mysqli/tests/015.phpt @@ -1,15 +1,15 @@ --TEST-- -mysqli autocommit/commit/rollback with myisam +mysqli autocommit/commit/rollback with innodb --SKIPIF-- - --EXPECTF-- array(2) { [0]=> - %s(1) "2" + string(1) "1" + [1]=> + string(6) "foobar" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(4) "egon" +} +done! +--UEXPECTF-- +array(2) { + [0]=> + unicode(1) "1" [1]=> - %s(4) "egon" + unicode(6) "foobar" } array(2) { [0]=> - %s(1) "2" + unicode(1) "2" [1]=> - %s(4) "egon" + unicode(4) "egon" } +done! \ No newline at end of file diff --git a/ext/mysqli/tests/016.phpt b/ext/mysqli/tests/016.phpt index 469795e710..7989bd330a 100644 --- a/ext/mysqli/tests/016.phpt +++ b/ext/mysqli/tests/016.phpt @@ -7,13 +7,14 @@ mysqli fetch user variable include "connect.inc"; /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); + $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); - mysqli_select_db($link, "test"); + if (!mysqli_query($link, "SET @dummy='foobar'")) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_query($link, "SET @dummy='foobar'"); - - $stmt = mysqli_prepare($link, "SELECT @dummy"); + if (!$stmt = mysqli_prepare($link, "SELECT @dummy")) + printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_bind_result($stmt, $dummy); mysqli_execute($stmt); mysqli_fetch($stmt); @@ -22,6 +23,11 @@ mysqli fetch user variable mysqli_stmt_close($stmt); mysqli_close($link); + print "done!"; ?> --EXPECTF-- -%s(6) "foobar" +string(6) "foobar" +done! +--UEXPECTF-- +unicode(6) "foobar" +done! diff --git a/ext/mysqli/tests/017.phpt b/ext/mysqli/tests/017.phpt index e8b19fb0da..912d5e28c3 100644 --- a/ext/mysqli/tests/017.phpt +++ b/ext/mysqli/tests/017.phpt @@ -8,11 +8,11 @@ mysqli fetch functions include "connect.inc"; /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); + $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); - mysqli_select_db($link, "test"); + if (!$stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'")) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'"); mysqli_bind_result($stmt, $c0, $c1, $c2); mysqli_execute($stmt); @@ -20,16 +20,31 @@ mysqli fetch functions mysqli_stmt_close($stmt); $test = array($c0, $c1, $c2); + if ($c1 !== $db) { + echo "Different data\n"; + } var_dump($test); mysqli_close($link); + print "done!"; ?> --EXPECTF-- array(3) { [0]=> - %s(32) "37b51d194a7513e45b56f6524f2d51f2" + string(32) "37b51d194a7513e45b56f6524f2d51f2" [1]=> - %s(4) "test" + string(%d) "%s" [2]=> - %s(3) "foo" + string(3) "foo" } +done! +--UEXPECTF-- +array(3) { + [0]=> + string(32) "37b51d194a7513e45b56f6524f2d51f2" + [1]=> + unicode(%d) "%s" + [2]=> + unicode(3) "foo" +} +done! diff --git a/ext/mysqli/tests/018.phpt b/ext/mysqli/tests/018.phpt index 4ba199d866..f62c52a3dd 100644 --- a/ext/mysqli/tests/018.phpt +++ b/ext/mysqli/tests/018.phpt @@ -5,16 +5,17 @@ mysqli fetch system variables --FILE-- --EXPECT-- int(0) +done! \ No newline at end of file diff --git a/ext/mysqli/tests/019.phpt b/ext/mysqli/tests/019.phpt index f0dd30b863..2fdc797e92 100644 --- a/ext/mysqli/tests/019.phpt +++ b/ext/mysqli/tests/019.phpt @@ -2,27 +2,29 @@ mysqli fetch (bind_param + bind_result) --SKIPIF-- ---INI-- -precision=14 --FILE-- --EXPECTF-- array(11) { @@ -67,7 +72,34 @@ array(11) { [8]=> NULL [9]=> - %s(3) "foo" + string(3) "foo" + [10]=> + string(6) "foobar" +} +done! +--UEXPECTF-- +array(11) { + [0]=> + int(1) + [1]=> + NULL + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL + [5]=> + float(3.14) + [6]=> + NULL + [7]=> + NULL + [8]=> + NULL + [9]=> + unicode(3) "foo" [10]=> - %s(6) "foobar" + unicode(6) "foobar" } +done! \ No newline at end of file