diff options
author | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
commit | 0fab6db7cac8d2be99579dd049f812a8ff98e74f (patch) | |
tree | 91f01b0d06916c78262404096bfd466b8e95e5b5 /ext/mysql/tests | |
parent | d3a8757891280dc6650ca7eead67830c794b0e7b (diff) | |
download | php-0fab6db7cac8d2be99579dd049f812a8ff98e74f.tar.gz |
Imported Upstream version 5.3.1upstream/5.3.1
Diffstat (limited to 'ext/mysql/tests')
63 files changed, 937 insertions, 1087 deletions
diff --git a/ext/mysql/tests/001.phpt b/ext/mysql/tests/001.phpt index de3957190..6f2e284de 100755 --- a/ext/mysql/tests/001.phpt +++ b/ext/mysql/tests/001.phpt @@ -25,9 +25,6 @@ mysql_close($db); var_dump($test); print "done!"; ?> ---EXPECT-- -string(2) "11" +--EXPECTF-- +%unicode|string%(2) "11" done! ---UEXPECTF-- -unicode(2) "11" -done!
\ No newline at end of file diff --git a/ext/mysql/tests/002.phpt b/ext/mysql/tests/002.phpt index 9c1250104..8355c5f11 100755 --- a/ext/mysql/tests/002.phpt +++ b/ext/mysql/tests/002.phpt @@ -32,6 +32,10 @@ mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- resource(%d) of type (mysql link) bool(true) @@ -39,42 +43,19 @@ bool(true) bool(true) resource(%d) of type (mysql result) array(3) { - ["col1"]=> - string(1) "1" - ["col2"]=> - string(3) "foo" - ["col3"]=> - string(3) "bar" + [%u|b%"col1"]=> + %unicode|string%(1) "1" + [%u|b%"col2"]=> + %unicode|string%(3) "foo" + [%u|b%"col3"]=> + %unicode|string%(3) "bar" } array(3) { - ["col1"]=> - string(1) "2" - ["col2"]=> - string(3) "foo" - ["col3"]=> - string(3) "bar" + [%u|b%"col1"]=> + %unicode|string%(1) "2" + [%u|b%"col2"]=> + %unicode|string%(3) "foo" + [%u|b%"col3"]=> + %unicode|string%(3) "bar" } done! ---UEXPECTF-- -resource(%d) of type (mysql link) -bool(true) -bool(true) -bool(true) -resource(%d) of type (mysql result) -array(3) { - [u"col1"]=> - unicode(1) "1" - [u"col2"]=> - unicode(3) "foo" - [u"col3"]=> - unicode(3) "bar" -} -array(3) { - [u"col1"]=> - unicode(1) "2" - [u"col2"]=> - unicode(3) "foo" - [u"col3"]=> - unicode(3) "bar" -} -done!
\ No newline at end of file diff --git a/ext/mysql/tests/003.phpt b/ext/mysql/tests/003.phpt index 0c3717b29..2d0b68b9f 100755 --- a/ext/mysql/tests/003.phpt +++ b/ext/mysql/tests/003.phpt @@ -52,65 +52,38 @@ mysql_free_result($res); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- ==stdClass== object(stdClass)#%d (1) { - ["a"]=> - string(3) "one" + [%u|b%"a"]=> + %unicode|string%(3) "one" } object(stdClass)#%d (1) { - ["a"]=> - string(3) "two" + [%u|b%"a"]=> + %unicode|string%(3) "two" } object(stdClass)#%d (1) { - ["a"]=> - string(5) "three" + [%u|b%"a"]=> + %unicode|string%(5) "three" } ==class24== class24::__construct object(class24)#%d (1) { - ["a"]=> - string(3) "one" + [%u|b%"a"]=> + %unicode|string%(3) "one" } class24::__construct object(class24)#%d (1) { - ["a"]=> - string(3) "two" + [%u|b%"a"]=> + %unicode|string%(3) "two" } class24::__construct object(class24)#%d (1) { - ["a"]=> - string(5) "three" + [%u|b%"a"]=> + %unicode|string%(5) "three" } done! ---UEXPECTF-- -==stdClass== -object(stdClass)#%d (1) { - [u"a"]=> - unicode(3) "one" -} -object(stdClass)#%d (1) { - [u"a"]=> - unicode(3) "two" -} -object(stdClass)#%d (1) { - [u"a"]=> - unicode(5) "three" -} -==class24== -class24::__construct -object(class24)#%d (1) { - [u"a"]=> - unicode(3) "one" -} -class24::__construct -object(class24)#%d (1) { - [u"a"]=> - unicode(3) "two" -} -class24::__construct -object(class24)#%d (1) { - [u"a"]=> - unicode(5) "three" -} -done!
\ No newline at end of file diff --git a/ext/mysql/tests/bug47438.phpt b/ext/mysql/tests/bug47438.phpt index 700c6d801..11f0ff33b 100644 --- a/ext/mysql/tests/bug47438.phpt +++ b/ext/mysql/tests/bug47438.phpt @@ -16,7 +16,7 @@ if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) mysql_select_db($db, $link); mysql_query("DROP TABLE IF EXISTS test_47438", $link); mysql_query("CREATE TABLE test_47438 (a INT, b INT, c INT)", $link); -mysql_query("INSERT INTO test_47438 VALUES (10, 11, 12), (20, 21, 22)", $link); +mysql_query("INSERT INTO test_47438 VALUES (10, 11, 12), (20, 21, 22)", $link); $result = mysql_query("SELECT * FROM test_47438", $link); mysql_field_seek($result, 1); @@ -32,6 +32,20 @@ while($i<mysql_num_fields($result)) mysql_query("DROP TABLE IF EXISTS test_47438", $link); ?> +--CLEAN-- +<?php +require_once('connect.inc'); + +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + +if (!mysql_select_db($db, $link) || + !mysql_query("DROP TABLE IF EXISTS test_47438", $link)) + printf("[c002] [%d] %s\n", mysql_errno($link), mysql_error($link)); + +mysql_close($link); +?> --EXPECT-- 0.a 1.b diff --git a/ext/mysql/tests/bug48754.phpt b/ext/mysql/tests/bug48754.phpt new file mode 100644 index 000000000..fb322f461 --- /dev/null +++ b/ext/mysql/tests/bug48754.phpt @@ -0,0 +1,92 @@ +--TEST-- +Bug #48754 (mysql_close() crash php when no handle specified) +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +?> +--FILE-- +<?php +require_once('connect.inc'); + +function my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket) { + if ($socket) + $host = sprintf("%s:%s", $host, $socket); + else if ($port) + $host = sprintf("%s:%s", $host, $port); + + if (!$link = mysql_pconnect($host, $user, $passwd, true)) { + printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n", + $host, $user, $passwd, + mysql_errno(), mysql_error()); + return false; + } + return $link; +} + +echo "Explicit connection on close\n"; +$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket); +$link1_thread_id = mysql_thread_id($link); +$default1_thread_id = mysql_thread_id(); +echo 'Expect same thread id for $link and default conn: '; +var_dump($link1_thread_id == $default1_thread_id); +var_dump($link); +mysql_close($link); +var_dump($link); + +// we sohuld have no default link anymore +mysql_close(); + +echo "\nClosing default link\n"; +$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket); +$link2_thread_id = mysql_thread_id($link); +$default2_thread_id = mysql_thread_id(); +echo 'Expect same thread id for $link and default conn but not the previous: '; +var_dump($link1_thread_id == $default1_thread_id && $link1_thread_id != $link2_thread_id); +var_dump($link); +mysql_close(); +var_dump($link); +mysql_close($link); +var_dump($link); + +echo "\nExplicit resource and pconnect\n"; +$link = my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket); +var_dump($link); +mysql_close($link); +var_dump($link); + +// we sohuld have no default link +mysql_close(); + +echo "\nDefault link and pconnect\n"; +$link = my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket); +var_dump($link); +mysql_close(); +var_dump($link); +mysql_close($link); +var_dump($link); +?> +--EXPECTF-- +Explicit connection on close +Expect same thread id for $link and default conn: bool(true) +resource(%d) of type (mysql link) +resource(%d) of type (Unknown) + +Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d + +Closing default link +Expect same thread id for $link and default conn but not the previous: bool(true) +resource(%d) of type (mysql link) +resource(%d) of type (mysql link) +resource(%d) of type (Unknown) + +Explicit resource and pconnect +resource(%d) of type (mysql link persistent) +resource(%d) of type (Unknown) + +Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d + +Default link and pconnect +resource(%d) of type (mysql link persistent) +resource(%d) of type (mysql link persistent) +resource(%d) of type (Unknown) diff --git a/ext/mysql/tests/clean_table.inc b/ext/mysql/tests/clean_table.inc new file mode 100644 index 000000000..e53245b43 --- /dev/null +++ b/ext/mysql/tests/clean_table.inc @@ -0,0 +1,15 @@ +<?PHP +require_once('connect.inc'); + +// connect + select_db +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[clean] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $myhost, $user, $db, $port, $socket); +} + +if (!mysql_query('DROP TABLE IF EXISTS test', $link)) { + printf("[clean] Failed to drop test table: [%d] %s\n", mysql_errno($link), mysql_error($link)); +} + +mysql_close($link); +?>
\ No newline at end of file diff --git a/ext/mysql/tests/connect.inc b/ext/mysql/tests/connect.inc index 70017b9e2..86c0ee674 100755 --- a/ext/mysql/tests/connect.inc +++ b/ext/mysql/tests/connect.inc @@ -20,14 +20,17 @@ if (!function_exists('sys_get_temp_dir')) { } /* wrapper to simplify test porting */ -function my_mysql_connect($host, $user, $passwd, $db, $port, $socket) { +function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) { + global $connect_flags; + + $flags = ($flags === NULL) ? $connect_flags : $flags; if ($socket) $host = sprintf("%s:%s", $host, $socket); else if ($port) $host = sprintf("%s:%s", $host, $port); - if (!$link = mysql_connect($host, $user, $passwd, true)) { + if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) { printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n", $host, $user, $passwd, mysql_errno(), mysql_error()); @@ -55,6 +58,7 @@ $db = getenv("MYSQL_TEST_DB") ? getenv("MYSQL_TEST_DB") : "test"; $engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM"; $socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null; $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true; +$connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0; /* Development setting: test experimal features and/or feature requests that never worked before? */ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ? diff --git a/ext/mysql/tests/mysql_affected_rows.phpt b/ext/mysql/tests/mysql_affected_rows.phpt index 9e2da44e3..ce16a7748 100644 --- a/ext/mysql/tests/mysql_affected_rows.phpt +++ b/ext/mysql/tests/mysql_affected_rows.phpt @@ -4,6 +4,7 @@ mysql_affected_rows() <?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); +require_once('skipifdefaultconnectfailure.inc'); ?> --FILE-- <?php @@ -12,8 +13,8 @@ include_once("connect.inc"); $tmp = NULL; $link = NULL; -if (false !== ($tmp = @mysql_affected_rows())) - printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); +if (0 !== ($tmp = @mysql_affected_rows())) + printf("[001] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (null !== ($tmp = @mysql_affected_rows($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); @@ -35,18 +36,18 @@ if (!mysql_query('DROP TABLE IF EXISTS test', $link)) if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine, $link)) printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); -if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link)) +if (!mysql_query("INSERT INTO test(id, label) VALUES (1, 'a')", $link)) printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (1 !== ($tmp = mysql_affected_rows($link))) printf("[010] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); // ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented -@mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link); +@mysql_query("INSERT INTO test(id, label) VALUES (1, 'a')", $link); if (-1 !== ($tmp = mysql_affected_rows($link))) printf("[011] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); -if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4', $link)) +if (!mysql_query("INSERT INTO test(id, label) VALUES (1, 'a') ON DUPLICATE KEY UPDATE id = 4", $link)) printf("[012] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (2 !== ($tmp = mysql_affected_rows($link))) @@ -116,5 +117,9 @@ if (false !== ($tmp = @mysql_affected_rows($link))) print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- done! diff --git a/ext/mysql/tests/mysql_client_encoding.phpt b/ext/mysql/tests/mysql_client_encoding.phpt index 399b1e870..8aa67a03a 100644 --- a/ext/mysql/tests/mysql_client_encoding.phpt +++ b/ext/mysql/tests/mysql_client_encoding.phpt @@ -50,7 +50,7 @@ if ($link_enc !== $tmp['charset']) { } } -if (ini_get('unicode.semantics') && function_exists('is_unicode')) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && function_exists('is_unicode')) { // unicode mode if (!is_unicode($default_link_enc) || !is_unicode($link_enc)) { printf("[010] No unicode returned!\n"); diff --git a/ext/mysql/tests/mysql_connect.phpt b/ext/mysql/tests/mysql_connect.phpt index ad10ea7f7..be094cce2 100644 --- a/ext/mysql/tests/mysql_connect.phpt +++ b/ext/mysql/tests/mysql_connect.phpt @@ -20,17 +20,23 @@ if (!$link = mysql_connect($myhost, $user, $passwd, true)) mysql_close($link); +if (!$link = mysql_connect($myhost, $user, $passwd, true)) + printf("[003] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $myhost, $user, $db, $port, $socket); + +mysql_close(); + if ($link = mysql_connect($myhost, $user . 'unknown_really', $passwd . 'non_empty', true)) - printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", + printf("[004] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user . 'unknown_really', $db, $port, $socket); if (false !== $link) -printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link); +printf("[005] Expecting boolean/false, got %s/%s\n", gettype($link), $link); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysql.default_socket', $socket); if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) { - printf("[005] Usage of mysql.default_socket failed\n"); + printf("[006] Usage of mysql.default_socket failed\n"); } else { mysql_close($link); } @@ -39,58 +45,55 @@ if (!ini_get('sql.safe_mode')) { ini_set('mysql.default_port', $port); if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) { - printf("[006] Usage of mysql.default_port failed\n"); + printf("[007] Usage of mysql.default_port failed\n"); } else { mysql_close($link); } ini_set('mysql.default_password', $passwd); if (!is_resource($link = mysql_connect($myhost, $user))) { - printf("[007] Usage of mysql.default_password failed\n"); + printf("[008] Usage of mysql.default_password failed\n"); } else { mysql_close($link); } ini_set('mysql.default_user', $user); if (!is_resource($link = mysql_connect($myhost))) { - printf("[008] Usage of mysql.default_user failed\n"); + printf("[009] Usage of mysql.default_user failed\n"); } else { mysql_close($link); } ini_set('mysql.default_host', $myhost); if (!is_resource($link = mysql_connect())) { - printf("[009] Usage of mysql.default_host failed\n") ; + printf("[010] Usage of mysql.default_host failed\n") ; } else { mysql_close($link); } + if (!is_resource($link = mysql_connect()) || !is_resource($link2 = mysql_connect())) { + printf("[011] Usage of mysql.default_host failed\n") ; + } else { + mysql_close(); + mysql_close($link2); + } + if (!stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'netware')) { ini_set('mysql.default_port', -1); if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port))) { if (!is_resource($link = mysql_connect())) { - printf("[010] Usage of env MYSQL_TCP_PORT failed\n") ; + printf("[012] Usage of env MYSQL_TCP_PORT failed\n") ; } else { mysql_close($link); } } else if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port + 1))) { if (!is_resource($link = mysql_connect())) { - printf("[011] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ; + printf("[013] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ; mysql_close($link); } } } } -/* we don't care if we can connect or not, this is just to test the different connect syntax variants */ -$myhost = sprintf('%s:%d', $host, $port ); -if ($link = mysql_connect($myhost, $user, $passwd, true)) - mysql_close($link); - -/* interesting, isn't it? */ -$myhost = sprintf('%s:%d', $host, $port , $socket); -if ($link = mysql_connect($myhost, $user, $passwd, true)) - mysql_close($link); - print "done!"; ?> --EXPECTF-- diff --git a/ext/mysql/tests/mysql_create_db.phpt b/ext/mysql/tests/mysql_create_db.phpt index 0a5d30e97..bc91964f5 100644 --- a/ext/mysql/tests/mysql_create_db.phpt +++ b/ext/mysql/tests/mysql_create_db.phpt @@ -40,5 +40,17 @@ if (!mysql_query("DROP DATABASE mysqlcreatedb", $link)) print "done!"; ?> +--CLEAN-- +<?php +require_once('connect.inc'); +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + +if (!mysql_query("DROP DATABASE IF EXISTS mysqlcreatedb", $link)) + printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + +mysql_close($link); +?> --EXPECTF-- done! diff --git a/ext/mysql/tests/mysql_data_seek.phpt b/ext/mysql/tests/mysql_data_seek.phpt index 687af1136..46a0f86bd 100644 --- a/ext/mysql/tests/mysql_data_seek.phpt +++ b/ext/mysql/tests/mysql_data_seek.phpt @@ -62,6 +62,10 @@ mysql_close($link); print "done!\n"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_data_seek(): Offset 4 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d diff --git a/ext/mysql/tests/mysql_db_name.phpt b/ext/mysql/tests/mysql_db_name.phpt index b1a03ed2c..be4f604d9 100644 --- a/ext/mysql/tests/mysql_db_name.phpt +++ b/ext/mysql/tests/mysql_db_name.phpt @@ -34,7 +34,7 @@ if (false !== ($tmp = mysql_db_name($res, $num + 1))) printf("[006] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); -$unicode = (boolean)ini_get('unicode.semantics'); +$unicode = (boolean)(version_compare(PHP_VERSION, '5.9.9', '>') == 1); for ($i = 0; $i < $num; $i++) { if ('' === ($dbname = mysql_db_name($res, $i))) printf("[%03d] Got empty database name! [%d] %s\n", diff --git a/ext/mysql/tests/mysql_db_query.phpt b/ext/mysql/tests/mysql_db_query.phpt index 8adf48171..bb837dd6c 100644 --- a/ext/mysql/tests/mysql_db_query.phpt +++ b/ext/mysql/tests/mysql_db_query.phpt @@ -32,7 +32,7 @@ $row = mysql_fetch_assoc($res); if (1 != $row['id']) printf("[005] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); -if (ini_get('unicode.semantics') && !is_unicode($row['label'])) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row['label'])) { printf("[006] No unicode returned! [%d] %s\n", mysql_errno($link), mysql_error($link)); var_inspect($row); } @@ -47,7 +47,7 @@ $row = mysql_fetch_assoc($res); if (1 != $row['id']) printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); -if (ini_get('unicode.semantics') && !is_unicode($row['label'])) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row['label'])) { printf("[009] No unicode returned! [%d] %s\n", mysql_errno(), mysql_error()); var_inspect($row); } @@ -57,5 +57,9 @@ mysql_close($link); print "done!\n"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- done! diff --git a/ext/mysql/tests/mysql_drop_db.phpt b/ext/mysql/tests/mysql_drop_db.phpt index fb42f7b22..bd729e7ab 100644 --- a/ext/mysql/tests/mysql_drop_db.phpt +++ b/ext/mysql/tests/mysql_drop_db.phpt @@ -39,5 +39,17 @@ mysql_close($link); print "done!\n"; ?> +--CLEAN-- +<?php +require_once('connect.inc'); +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + +if (!mysql_query("DROP DATABASE IF EXISTS mysqldropdb", $link)) + printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + +mysql_close($link); +?> --EXPECTF-- done!
\ No newline at end of file diff --git a/ext/mysql/tests/mysql_errno.phpt b/ext/mysql/tests/mysql_errno.phpt index 7a9e85fb3..8cfa7bd33 100644 --- a/ext/mysql/tests/mysql_errno.phpt +++ b/ext/mysql/tests/mysql_errno.phpt @@ -50,6 +50,10 @@ if ($link = @mysql_connect($host . '_unknown', $user . '_unknown', $passwd, true print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- int(0) int(%d) diff --git a/ext/mysql/tests/mysql_error.phpt b/ext/mysql/tests/mysql_error.phpt index b64982a42..aae448017 100644 --- a/ext/mysql/tests/mysql_error.phpt +++ b/ext/mysql/tests/mysql_error.phpt @@ -39,7 +39,7 @@ $tmp = mysql_error($link); if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp)) printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); -if (ini_get('unicode.semantics') && !is_unicode($tmp)) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp)) { printf("[007] Expecting Unicode error message!\n"); var_inspect($tmp); } @@ -57,6 +57,10 @@ if ('' == mysql_error()) print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_error(): %d is not a valid MySQL-Link resource in %s on line %d bool(false) diff --git a/ext/mysql/tests/mysql_escape_string.phpt b/ext/mysql/tests/mysql_escape_string.phpt index 1badea890..45bf26978 100644 --- a/ext/mysql/tests/mysql_escape_string.phpt +++ b/ext/mysql/tests/mysql_escape_string.phpt @@ -23,20 +23,11 @@ var_dump(mysql_escape_string("foo" . chr(0) . "bar")); print "done!"; ?> --EXPECTF-- -string(31) "Am I a unicode string in PHP 6?" -string(2) "\\" -string(2) "\"" -string(2) "\'" -string(2) "\n" -string(2) "\r" -string(8) "foo\0bar" +%unicode|string%(31) "Am I a unicode string in PHP 6?" +%unicode|string%(2) "\\" +%unicode|string%(2) "\"" +%unicode|string%(2) "\'" +%unicode|string%(2) "\n" +%unicode|string%(2) "\r" +%unicode|string%(8) "foo\0bar" done! ---UEXPECTF-- -unicode(31) "Am I a unicode string in PHP 6?" -unicode(2) "\\" -unicode(2) "\"" -unicode(2) "\'" -unicode(2) "\n" -unicode(2) "\r" -unicode(8) "foo\0bar" -done!
\ No newline at end of file diff --git a/ext/mysql/tests/mysql_fetch_array.phpt b/ext/mysql/tests/mysql_fetch_array.phpt index 729523514..635e6d109 100644 --- a/ext/mysql/tests/mysql_fetch_array.phpt +++ b/ext/mysql/tests/mysql_fetch_array.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_fetch_array() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -56,7 +56,7 @@ exit(1); do { $illegal_mode = mt_rand(0, 10000); } while (in_array($illegal_mode, array(MYSQL_ASSOC, MYSQL_NUM, MYSQL_BOTH))); -$tmp = @mysql_fetch_array($res, $illegal_mode); +$tmp = mysql_fetch_array($res, $illegal_mode); if (!is_array($tmp)) printf("[013] Expecting array, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysql_errno($link), mysql_error($link)); @@ -277,155 +277,85 @@ printf("[015] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- [005] array(4) { [0]=> - string(1) "1" - ["id"]=> - string(1) "1" + %unicode|string%(1) "1" + [%u|b%"id"]=> + %unicode|string%(1) "1" [1]=> - string(1) "a" - ["label"]=> - string(1) "a" + %unicode|string%(1) "a" + [%u|b%"label"]=> + %unicode|string%(1) "a" } [006] array(2) { [0]=> - string(1) "2" + %unicode|string%(1) "2" [1]=> - string(1) "b" + %unicode|string%(1) "b" } [007] array(4) { [0]=> - string(1) "3" - ["id"]=> - string(1) "3" + %unicode|string%(1) "3" + [%u|b%"id"]=> + %unicode|string%(1) "3" [1]=> - string(1) "c" - ["label"]=> - string(1) "c" + %unicode|string%(1) "c" + [%u|b%"label"]=> + %unicode|string%(1) "c" } [008] array(2) { - ["id"]=> - string(1) "4" - ["label"]=> - string(1) "d" + [%u|b%"id"]=> + %unicode|string%(1) "4" + [%u|b%"label"]=> + %unicode|string%(1) "d" } [009] array(4) { [0]=> - string(1) "5" - ["id"]=> - string(1) "5" + %unicode|string%(1) "5" + [%u|b%"id"]=> + %unicode|string%(1) "5" [1]=> - string(1) "e" - ["label"]=> - string(1) "e" + %unicode|string%(1) "e" + [%u|b%"label"]=> + %unicode|string%(1) "e" } [011] array(11) { [0]=> - string(1) "1" - ["a"]=> - string(1) "2" + %unicode|string%(1) "1" + [%u|b%"a"]=> + %unicode|string%(1) "2" [1]=> - string(1) "2" + %unicode|string%(1) "2" [2]=> - string(1) "3" - ["c"]=> - string(1) "3" + %unicode|string%(1) "3" + [%u|b%"c"]=> + %unicode|string%(1) "3" [3]=> - string(1) "4" - ["C"]=> - string(1) "4" + %unicode|string%(1) "4" + [%u|b%"C"]=> + %unicode|string%(1) "4" [4]=> NULL - ["d"]=> + [%u|b%"d"]=> NULL [5]=> - string(1) "1" - ["e"]=> - string(1) "1" + %unicode|string%(1) "1" + [%u|b%"e"]=> + %unicode|string%(1) "1" } -Warning: mysql_fetch_array(): %d is not a valid MySQL result resource in %s on line %d -done! ---UEXPECTF-- -[005] -array(4) { - [0]=> - unicode(1) "1" - [u"id"]=> - unicode(1) "1" - [1]=> - unicode(1) "a" - [u"label"]=> - unicode(1) "a" -} -[006] -array(2) { - [0]=> - unicode(1) "2" - [1]=> - unicode(1) "b" -} -[007] -array(4) { - [0]=> - unicode(1) "3" - [u"id"]=> - unicode(1) "3" - [1]=> - unicode(1) "c" - [u"label"]=> - unicode(1) "c" -} -[008] -array(2) { - [u"id"]=> - unicode(1) "4" - [u"label"]=> - unicode(1) "d" -} -[009] -array(4) { - [0]=> - unicode(1) "5" - [u"id"]=> - unicode(1) "5" - [1]=> - unicode(1) "e" - [u"label"]=> - unicode(1) "e" -} -[011] -array(11) { - [0]=> - unicode(1) "1" - [u"a"]=> - unicode(1) "2" - [1]=> - unicode(1) "2" - [2]=> - unicode(1) "3" - [u"c"]=> - unicode(1) "3" - [3]=> - unicode(1) "4" - [u"C"]=> - unicode(1) "4" - [4]=> - NULL - [u"d"]=> - NULL - [5]=> - unicode(1) "1" - [u"e"]=> - unicode(1) "1" -} +Warning: mysql_fetch_array(): The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH in %s on line %d Warning: mysql_fetch_array(): %d is not a valid MySQL result resource in %s on line %d done! diff --git a/ext/mysql/tests/mysql_fetch_assoc.phpt b/ext/mysql/tests/mysql_fetch_assoc.phpt index 4479a2ab3..3c5ca79b2 100644 --- a/ext/mysql/tests/mysql_fetch_assoc.phpt +++ b/ext/mysql/tests/mysql_fetch_assoc.phpt @@ -58,81 +58,46 @@ mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- [005] array(2) { - ["id"]=> - string(1) "1" - ["label"]=> - string(1) "a" -} -[006] -bool(false) -[008] -array(5) { - ["a"]=> - string(1) "2" - ["c"]=> - string(1) "3" - ["C"]=> - string(1) "4" - ["d"]=> - NULL - ["e"]=> - string(1) "1" -} - -Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d -[010] -array(5) { - ["id"]=> - string(1) "1" - ["label"]=> - string(1) "a" - ["_id"]=> - string(1) "1" - ["_label"]=> - string(2) "aa" - ["_foo"]=> - NULL -} -done! ---UEXPECTF-- -[005] -array(2) { - [u"id"]=> - unicode(1) "1" - [u"label"]=> - unicode(1) "a" + [%u|b%"id"]=> + %unicode|string%(1) "1" + [%u|b%"label"]=> + %unicode|string%(1) "a" } [006] bool(false) [008] array(5) { - [u"a"]=> - unicode(1) "2" - [u"c"]=> - unicode(1) "3" - [u"C"]=> - unicode(1) "4" - [u"d"]=> + [%u|b%"a"]=> + %unicode|string%(1) "2" + [%u|b%"c"]=> + %unicode|string%(1) "3" + [%u|b%"C"]=> + %unicode|string%(1) "4" + [%u|b%"d"]=> NULL - [u"e"]=> - unicode(1) "1" + [%u|b%"e"]=> + %unicode|string%(1) "1" } Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d [010] array(5) { - [u"id"]=> - unicode(1) "1" - [u"label"]=> - unicode(1) "a" - [u"_id"]=> - unicode(1) "1" - [u"_label"]=> - unicode(2) "aa" - [u"_foo"]=> + [%u|b%"id"]=> + %unicode|string%(1) "1" + [%u|b%"label"]=> + %unicode|string%(1) "a" + [%u|b%"_id"]=> + %unicode|string%(1) "1" + [%u|b%"_label"]=> + %unicode|string%(2) "aa" + [%u|b%"_foo"]=> NULL } done! diff --git a/ext/mysql/tests/mysql_fetch_field.phpt b/ext/mysql/tests/mysql_fetch_field.phpt index c46335f9d..65c44edc5 100644 --- a/ext/mysql/tests/mysql_fetch_field.phpt +++ b/ext/mysql/tests/mysql_fetch_field.phpt @@ -39,13 +39,13 @@ require_once('skipifconnectfailure.inc'); if (!$res = mysql_query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1", $link)) { printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); } - if (false !== ($tmp = mysql_fetch_field($res, PHP_INT_MAX * 2))) - printf("[006] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = mysql_fetch_field($res, PHP_INT_MAX - 1))) + printf("[006] Expecting boolean/false got %s/%s\n", gettype($tmp), var_export($tmp, true)); mysql_free_result($res); if (false !== ($tmp = mysql_fetch_field($res))) - printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true)); $types = array( 'BIT' => array(1, 'int'), @@ -124,189 +124,81 @@ require_once('skipifconnectfailure.inc'); printf("[017] [%d] %s\n", mysql_errno($link), mysql_error($link)); } $res = mysql_list_fields($db, 'test'); - while ($tmp = mysql_fetch_field($res)) - if ($tmp->name == 'id') + $found = false; + while ($tmp = mysql_fetch_field($res)) { + if ($tmp->name == 'id') { + printf("Fetch field from mysql_list_fields result set.\n"); + $found = true; var_dump($tmp); + } + } + if (!$found) + printf("[018] mysqli_list_fields result set processing has failed.\n"); mysql_free_result($res); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- object(stdClass)#%d (13) { - ["name"]=> - string(2) "ID" - ["table"]=> - string(4) "TEST" - ["def"]=> - string(0) "" - ["max_length"]=> - int(1) - ["not_null"]=> - int(1) - ["primary_key"]=> - int(1) - ["multiple_key"]=> - int(0) - ["unique_key"]=> - int(0) - ["numeric"]=> - int(1) - ["blob"]=> - int(0) - ["type"]=> - string(3) "int" - ["unsigned"]=> - int(0) - ["zerofill"]=> - int(0) -} -object(stdClass)#%d (13) { - ["name"]=> - string(5) "label" - ["table"]=> - string(4) "TEST" - ["def"]=> - string(0) "" - ["max_length"]=> - int(1) - ["not_null"]=> - int(0) - ["primary_key"]=> - int(0) - ["multiple_key"]=> - int(0) - ["unique_key"]=> - int(0) - ["numeric"]=> - int(0) - ["blob"]=> - int(0) - ["type"]=> - string(6) "string" - ["unsigned"]=> - int(0) - ["zerofill"]=> - int(0) -} -bool(false) - -Warning: mysql_fetch_field(): Bad field offset in %s on line %d - -Warning: mysql_fetch_field(): %d is not a valid MySQL result resource in %s on line %d -object(stdClass)#%d (13) { - ["name"]=> - string(2) "id" - ["table"]=> - string(4) "test" - ["def"]=> - string(0) "" - ["max_length"]=> - int(1) - ["not_null"]=> - int(0) - ["primary_key"]=> - int(0) - ["multiple_key"]=> - int(0) - ["unique_key"]=> - int(0) - ["numeric"]=> - int(1) - ["blob"]=> - int(0) - ["type"]=> - string(3) "int" - ["unsigned"]=> - int(0) - ["zerofill"]=> - int(0) -} -object(stdClass)#%d (13) { - ["name"]=> - string(2) "id" - ["table"]=> - string(4) "test" - ["def"]=> - string(1) "1" - ["max_length"]=> - int(0) - ["not_null"]=> - int(0) - ["primary_key"]=> - int(0) - ["multiple_key"]=> - int(0) - ["unique_key"]=> - int(0) - ["numeric"]=> - int(1) - ["blob"]=> - int(0) - ["type"]=> - string(3) "int" - ["unsigned"]=> - int(0) - ["zerofill"]=> - int(0) -} -done! ---UEXPECTF-- -object(stdClass)#%d (13) { - [u"name"]=> - unicode(2) "ID" - [u"table"]=> - unicode(4) "TEST" - [u"def"]=> - unicode(0) "" - [u"max_length"]=> + [%u|b%"name"]=> + %unicode|string%(2) "ID" + [%u|b%"table"]=> + %unicode|string%(4) "TEST" + [%u|b%"def"]=> + %unicode|string%(0) "" + [%u|b%"max_length"]=> int(1) - [u"not_null"]=> + [%u|b%"not_null"]=> int(1) - [u"primary_key"]=> + [%u|b%"primary_key"]=> int(1) - [u"multiple_key"]=> + [%u|b%"multiple_key"]=> int(0) - [u"unique_key"]=> + [%u|b%"unique_key"]=> int(0) - [u"numeric"]=> + [%u|b%"numeric"]=> int(1) - [u"blob"]=> + [%u|b%"blob"]=> int(0) - [u"type"]=> - unicode(3) "int" - [u"unsigned"]=> + [%u|b%"type"]=> + %unicode|string%(3) "int" + [%u|b%"unsigned"]=> int(0) - [u"zerofill"]=> + [%u|b%"zerofill"]=> int(0) } object(stdClass)#%d (13) { - [u"name"]=> - unicode(5) "label" - [u"table"]=> - unicode(4) "TEST" - [u"def"]=> - unicode(0) "" - [u"max_length"]=> + [%u|b%"name"]=> + %unicode|string%(5) "label" + [%u|b%"table"]=> + %unicode|string%(4) "TEST" + [%u|b%"def"]=> + %unicode|string%(0) "" + [%u|b%"max_length"]=> int(1) - [u"not_null"]=> + [%u|b%"not_null"]=> int(0) - [u"primary_key"]=> + [%u|b%"primary_key"]=> int(0) - [u"multiple_key"]=> + [%u|b%"multiple_key"]=> int(0) - [u"unique_key"]=> + [%u|b%"unique_key"]=> int(0) - [u"numeric"]=> + [%u|b%"numeric"]=> int(0) - [u"blob"]=> + [%u|b%"blob"]=> int(0) - [u"type"]=> - unicode(6) "string" - [u"unsigned"]=> + [%u|b%"type"]=> + %unicode|string%(6) "string" + [%u|b%"unsigned"]=> int(0) - [u"zerofill"]=> + [%u|b%"zerofill"]=> int(0) } bool(false) @@ -315,59 +207,60 @@ Warning: mysql_fetch_field(): Bad field offset in %s on line %d Warning: mysql_fetch_field(): %d is not a valid MySQL result resource in %s on line %d object(stdClass)#%d (13) { - [u"name"]=> - unicode(2) "id" - [u"table"]=> - unicode(4) "test" - [u"def"]=> - unicode(0) "" - [u"max_length"]=> + [%u|b%"name"]=> + %unicode|string%(2) "id" + [%u|b%"table"]=> + %unicode|string%(4) "test" + [%u|b%"def"]=> + %unicode|string%(0) "" + [%u|b%"max_length"]=> int(1) - [u"not_null"]=> + [%u|b%"not_null"]=> int(0) - [u"primary_key"]=> + [%u|b%"primary_key"]=> int(0) - [u"multiple_key"]=> + [%u|b%"multiple_key"]=> int(0) - [u"unique_key"]=> + [%u|b%"unique_key"]=> int(0) - [u"numeric"]=> + [%u|b%"numeric"]=> int(1) - [u"blob"]=> + [%u|b%"blob"]=> int(0) - [u"type"]=> - unicode(3) "int" - [u"unsigned"]=> + [%u|b%"type"]=> + %unicode|string%(3) "int" + [%u|b%"unsigned"]=> int(0) - [u"zerofill"]=> + [%u|b%"zerofill"]=> int(0) } +Fetch field from mysql_list_fields result set. object(stdClass)#%d (13) { - [u"name"]=> - unicode(2) "id" - [u"table"]=> - unicode(4) "test" - [u"def"]=> - unicode(1) "1" - [u"max_length"]=> + [%u|b%"name"]=> + %unicode|string%(2) "id" + [%u|b%"table"]=> + %unicode|string%(4) "test" + [%u|b%"def"]=> + %unicode|string%(1) "1" + [%u|b%"max_length"]=> int(0) - [u"not_null"]=> + [%u|b%"not_null"]=> int(0) - [u"primary_key"]=> + [%u|b%"primary_key"]=> int(0) - [u"multiple_key"]=> + [%u|b%"multiple_key"]=> int(0) - [u"unique_key"]=> + [%u|b%"unique_key"]=> int(0) - [u"numeric"]=> + [%u|b%"numeric"]=> int(1) - [u"blob"]=> + [%u|b%"blob"]=> int(0) - [u"type"]=> - unicode(3) "int" - [u"unsigned"]=> + [%u|b%"type"]=> + %unicode|string%(3) "int" + [%u|b%"unsigned"]=> int(0) - [u"zerofill"]=> + [%u|b%"zerofill"]=> int(0) } done! diff --git a/ext/mysql/tests/mysql_fetch_lengths.phpt b/ext/mysql/tests/mysql_fetch_lengths.phpt index 4b181765b..4793e2649 100644 --- a/ext/mysql/tests/mysql_fetch_lengths.phpt +++ b/ext/mysql/tests/mysql_fetch_lengths.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_fetch_lengths() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -34,6 +34,10 @@ var_dump(mysql_fetch_lengths($res)); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- array(2) { [0]=> diff --git a/ext/mysql/tests/mysql_fetch_object.phpt b/ext/mysql/tests/mysql_fetch_object.phpt index cc20f738b..c11631e04 100644 --- a/ext/mysql/tests/mysql_fetch_object.phpt +++ b/ext/mysql/tests/mysql_fetch_object.phpt @@ -77,91 +77,26 @@ var_dump(mysql_fetch_object($res, 'this_class_does_not_exist')); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- object(stdClass)#%d (2) { - ["ID"]=> - string(1) "1" - ["label"]=> - string(1) "a" -} -object(mysql_fetch_object_test)#%d (4) { - ["a"]=> - NULL - ["b"]=> - NULL - ["ID"]=> - string(1) "2" - ["label"]=> - string(1) "b" -} - -Warning: Missing argument 1 for mysql_fetch_object_construct::__construct() in %s on line %d - -Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d - -Notice: Undefined variable: a in %s on line %d - -Notice: Undefined variable: b in %s on line %d -object(mysql_fetch_object_construct)#%d (4) { - ["a"]=> - NULL - ["b"]=> - NULL - ["ID"]=> - string(1) "3" - ["label"]=> - string(1) "c" -} - -Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d - -Notice: Undefined variable: b in %s on line %d -object(mysql_fetch_object_construct)#%d (4) { - ["a"]=> - string(1) "a" - ["b"]=> - NULL - ["ID"]=> - string(1) "4" - ["label"]=> - string(1) "d" -} -object(mysql_fetch_object_construct)#%d (4) { - ["a"]=> - string(1) "a" - ["b"]=> - string(1) "b" - ["ID"]=> - string(1) "5" - ["label"]=> - string(1) "e" -} -bool(false) -bool(false) -bool(false) -bool(false) -bool(false) - -Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d -bool(false) - -Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d ---UEXPECTF-- -object(stdClass)#%d (2) { - [u"ID"]=> - unicode(1) "1" - [u"label"]=> - unicode(1) "a" + [%u|b%"ID"]=> + %unicode|string%(1) "1" + [%u|b%"label"]=> + %unicode|string%(1) "a" } object(mysql_fetch_object_test)#%d (4) { - [u"a"]=> + [%u|b%"a"]=> NULL - [u"b"]=> + [%u|b%"b"]=> NULL - [u"ID"]=> - unicode(1) "2" - [u"label"]=> - unicode(1) "b" + [%u|b%"ID"]=> + %unicode|string%(1) "2" + [%u|b%"label"]=> + %unicode|string%(1) "b" } Warning: Missing argument 1 for mysql_fetch_object_construct::__construct() in %s on line %d @@ -172,38 +107,38 @@ Notice: Undefined variable: a in %s on line %d Notice: Undefined variable: b in %s on line %d object(mysql_fetch_object_construct)#%d (4) { - [u"a"]=> + [%u|b%"a"]=> NULL - [u"b"]=> + [%u|b%"b"]=> NULL - [u"ID"]=> - unicode(1) "3" - [u"label"]=> - unicode(1) "c" + [%u|b%"ID"]=> + %unicode|string%(1) "3" + [%u|b%"label"]=> + %unicode|string%(1) "c" } Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d Notice: Undefined variable: b in %s on line %d object(mysql_fetch_object_construct)#%d (4) { - [u"a"]=> - unicode(1) "a" - [u"b"]=> + [%u|b%"a"]=> + %unicode|string%(1) "a" + [%u|b%"b"]=> NULL - [u"ID"]=> - unicode(1) "4" - [u"label"]=> - unicode(1) "d" + [%u|b%"ID"]=> + %unicode|string%(1) "4" + [%u|b%"label"]=> + %unicode|string%(1) "d" } object(mysql_fetch_object_construct)#%d (4) { - [u"a"]=> - unicode(1) "a" - [u"b"]=> - unicode(1) "b" - [u"ID"]=> - unicode(1) "5" - [u"label"]=> - unicode(1) "e" + [%u|b%"a"]=> + %unicode|string%(1) "a" + [%u|b%"b"]=> + %unicode|string%(1) "b" + [%u|b%"ID"]=> + %unicode|string%(1) "5" + [%u|b%"label"]=> + %unicode|string%(1) "e" } bool(false) bool(false) diff --git a/ext/mysql/tests/mysql_fetch_row.phpt b/ext/mysql/tests/mysql_fetch_row.phpt index d9fff217a..8d6b9585b 100644 --- a/ext/mysql/tests/mysql_fetch_row.phpt +++ b/ext/mysql/tests/mysql_fetch_row.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_fetch_row() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -36,31 +36,21 @@ var_dump(mysql_fetch_row($res)); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- [004] array(2) { [0]=> - string(1) "1" - [1]=> - string(1) "a" -} -[005] -bool(false) - -Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d -bool(false) -done! ---UEXPECTF-- -[004] -array(2) { - [0]=> - unicode(1) "1" + %unicode|string%(1) "1" [1]=> - unicode(1) "a" + %unicode|string%(1) "a" } [005] bool(false) Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d bool(false) -done! +done!
\ No newline at end of file diff --git a/ext/mysql/tests/mysql_field_flags.phpt b/ext/mysql/tests/mysql_field_flags.phpt index c609123cc..6489affc1 100644 --- a/ext/mysql/tests/mysql_field_flags.phpt +++ b/ext/mysql/tests/mysql_field_flags.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_field_flags() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -32,7 +32,7 @@ if (false !== ($tmp = mysql_field_flags($res, -1))) if (!is_string($tmp = mysql_field_flags($res, 0)) || empty($tmp)) printf("[006] Expecting non empty string, got %s/%s\n", gettype($tmp), $tmp); -if (ini_get('unicode.semantics') && !is_unicode($tmp)) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp)) { printf("[007] Check the unicode support!\n"); var_inspect($tmp); } @@ -53,11 +53,11 @@ $tables = array( 'label' => array(($version < 500) ? 'multiple_key' : 'unique_key') ), 'labela INT, label2 CHAR(1), KEY keyname (labela, label2)' => array( - array('labela, label2', '1, "a"'), + array('labela, label2', "1, 'a'"), 'labela' => array('multiple_key'), ), 'label1 BLOB' => array( - array('label1', '"blob"'), + array('label1', "'blob'"), 'label1' => array('blob', 'binary'), ), 'label1 INT UNSIGNED' => array( @@ -70,15 +70,15 @@ $tables = array( 'unsigned'), ), 'label1 ENUM("a", "b")' => array( - array('label1', '"a"'), + array('label1', "'a'"), 'label1' => array('enum'), ), 'label1 SET("a", "b")' => array( - array('label1', '"a"'), + array('label1', "'a'"), 'label1' => array('set'), ), 'label1 TIMESTAMP' => array( - array('label1', sprintf('"%s"', @date("Y-m-d H:i:s"))), + array('label1', sprintf("'%s'", @date("Y-m-d H:i:s"))), 'label1' => array( 'timestamp', 'unsigned', @@ -135,6 +135,10 @@ var_dump(mysql_field_flags($res, 0)); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_field_flags() expects exactly 2 parameters, 1 given in %s on line %d diff --git a/ext/mysql/tests/mysql_field_len.phpt b/ext/mysql/tests/mysql_field_len.phpt index a81e36a68..a740c6243 100644 --- a/ext/mysql/tests/mysql_field_len.phpt +++ b/ext/mysql/tests/mysql_field_len.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_field_len() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -42,6 +42,10 @@ var_dump(mysql_field_len($res, 0)); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_field_len() expects exactly 2 parameters, 1 given in %s on line %d diff --git a/ext/mysql/tests/mysql_field_name.phpt b/ext/mysql/tests/mysql_field_name.phpt index aeb516c8b..c87ac188f 100644 --- a/ext/mysql/tests/mysql_field_name.phpt +++ b/ext/mysql/tests/mysql_field_name.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_field_name() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -41,22 +41,15 @@ var_dump(mysql_field_name($res, 0)); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_field_name() expects exactly 2 parameters, 1 given in %s on line %d Warning: mysql_field_name(): Field -1 is invalid for MySQL result index %d in %s on line %d -string(2) "id" - -Warning: mysql_field_name(): Field 2 is invalid for MySQL result index %d in %s on line %d - -Warning: mysql_field_name(): %d is not a valid MySQL result resource in %s on line %d -bool(false) -done! ---UEXPECTF-- -Warning: Wrong parameter count for mysql_field_name() in %s on line %d - -Warning: mysql_field_name(): Field -1 is invalid for MySQL result index %d in %s on line %d -unicode(2) "id" +%unicode|string%(2) "id" Warning: mysql_field_name(): Field 2 is invalid for MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_field_seek.phpt b/ext/mysql/tests/mysql_field_seek.phpt index e5105d984..7e8b313c8 100644 --- a/ext/mysql/tests/mysql_field_seek.phpt +++ b/ext/mysql/tests/mysql_field_seek.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_field_seek() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -39,190 +39,97 @@ var_dump(mysql_field_seek($res, 0)); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d bool(false) object(stdClass)#%d (13) { - ["name"]=> - string(2) "id" - ["table"]=> - string(4) "test" - ["def"]=> - string(0) "" - ["max_length"]=> - int(1) - ["not_null"]=> - int(1) - ["primary_key"]=> - int(1) - ["multiple_key"]=> - int(0) - ["unique_key"]=> - int(0) - ["numeric"]=> - int(1) - ["blob"]=> - int(0) - ["type"]=> - string(3) "int" - ["unsigned"]=> - int(0) - ["zerofill"]=> - int(0) -} -bool(true) -object(stdClass)#%d (13) { - ["name"]=> - string(2) "id" - ["table"]=> - string(4) "test" - ["def"]=> - string(0) "" - ["max_length"]=> - int(1) - ["not_null"]=> - int(1) - ["primary_key"]=> - int(1) - ["multiple_key"]=> - int(0) - ["unique_key"]=> - int(0) - ["numeric"]=> - int(1) - ["blob"]=> - int(0) - ["type"]=> - string(3) "int" - ["unsigned"]=> - int(0) - ["zerofill"]=> - int(0) -} -bool(true) -object(stdClass)#%d (13) { - ["name"]=> - string(5) "label" - ["table"]=> - string(4) "test" - ["def"]=> - string(0) "" - ["max_length"]=> - int(1) - ["not_null"]=> - int(0) - ["primary_key"]=> - int(0) - ["multiple_key"]=> - int(0) - ["unique_key"]=> - int(0) - ["numeric"]=> - int(0) - ["blob"]=> - int(0) - ["type"]=> - string(6) "string" - ["unsigned"]=> - int(0) - ["zerofill"]=> - int(0) -} - -Warning: mysql_field_seek(): Field %d is invalid for MySQL result index %d in %s on line %d -bool(false) -bool(false) - -Warning: mysql_field_seek(): %d is not a valid MySQL result resource in %s on line %d -bool(false) -done! ---UEXPECTF-- -Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d -bool(false) -object(stdClass)#%d (13) { - [u"name"]=> - unicode(2) "id" - [u"table"]=> - unicode(4) "test" - [u"def"]=> - unicode(0) "" - [u"max_length"]=> + [%u|b%"name"]=> + %unicode|string%(2) "id" + [%u|b%"table"]=> + %unicode|string%(4) "test" + [%u|b%"def"]=> + %unicode|string%(0) "" + [%u|b%"max_length"]=> int(1) - [u"not_null"]=> + [%u|b%"not_null"]=> int(1) - [u"primary_key"]=> + [%u|b%"primary_key"]=> int(1) - [u"multiple_key"]=> + [%u|b%"multiple_key"]=> int(0) - [u"unique_key"]=> + [%u|b%"unique_key"]=> int(0) - [u"numeric"]=> + [%u|b%"numeric"]=> int(1) - [u"blob"]=> + [%u|b%"blob"]=> int(0) - [u"type"]=> - unicode(3) "int" - [u"unsigned"]=> + [%u|b%"type"]=> + %unicode|string%(3) "int" + [%u|b%"unsigned"]=> int(0) - [u"zerofill"]=> + [%u|b%"zerofill"]=> int(0) } bool(true) object(stdClass)#%d (13) { - [u"name"]=> - unicode(2) "id" - [u"table"]=> - unicode(4) "test" - [u"def"]=> - unicode(0) "" - [u"max_length"]=> + [%u|b%"name"]=> + %unicode|string%(2) "id" + [%u|b%"table"]=> + %unicode|string%(4) "test" + [%u|b%"def"]=> + %unicode|string%(0) "" + [%u|b%"max_length"]=> int(1) - [u"not_null"]=> + [%u|b%"not_null"]=> int(1) - [u"primary_key"]=> + [%u|b%"primary_key"]=> int(1) - [u"multiple_key"]=> + [%u|b%"multiple_key"]=> int(0) - [u"unique_key"]=> + [%u|b%"unique_key"]=> int(0) - [u"numeric"]=> + [%u|b%"numeric"]=> int(1) - [u"blob"]=> + [%u|b%"blob"]=> int(0) - [u"type"]=> - unicode(3) "int" - [u"unsigned"]=> + [%u|b%"type"]=> + %unicode|string%(3) "int" + [%u|b%"unsigned"]=> int(0) - [u"zerofill"]=> + [%u|b%"zerofill"]=> int(0) } bool(true) object(stdClass)#%d (13) { - [u"name"]=> - unicode(5) "label" - [u"table"]=> - unicode(4) "test" - [u"def"]=> - unicode(0) "" - [u"max_length"]=> + [%u|b%"name"]=> + %unicode|string%(5) "label" + [%u|b%"table"]=> + %unicode|string%(4) "test" + [%u|b%"def"]=> + %unicode|string%(0) "" + [%u|b%"max_length"]=> int(1) - [u"not_null"]=> + [%u|b%"not_null"]=> int(0) - [u"primary_key"]=> + [%u|b%"primary_key"]=> int(0) - [u"multiple_key"]=> + [%u|b%"multiple_key"]=> int(0) - [u"unique_key"]=> + [%u|b%"unique_key"]=> int(0) - [u"numeric"]=> + [%u|b%"numeric"]=> int(0) - [u"blob"]=> + [%u|b%"blob"]=> int(0) - [u"type"]=> - unicode(6) "string" - [u"unsigned"]=> + [%u|b%"type"]=> + %unicode|string%(6) "string" + [%u|b%"unsigned"]=> int(0) - [u"zerofill"]=> + [%u|b%"zerofill"]=> int(0) } diff --git a/ext/mysql/tests/mysql_field_table.phpt b/ext/mysql/tests/mysql_field_table.phpt index 5e552f8ee..707d1df98 100644 --- a/ext/mysql/tests/mysql_field_table.phpt +++ b/ext/mysql/tests/mysql_field_table.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_field_table() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -41,22 +41,15 @@ var_dump(mysql_field_table($res, 0)); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_field_table() expects exactly 2 parameters, 1 given in %s on line %d Warning: mysql_field_table(): Field -1 is invalid for MySQL result index %d in %s on line %d -string(4) "test" - -Warning: mysql_field_table(): Field 2 is invalid for MySQL result index %d in %s on line %d - -Warning: mysql_field_table(): %d is not a valid MySQL result resource in %s on line %d -bool(false) -done! ---UEXPECTF-- -Warning: Wrong parameter count for mysql_field_table() in %s on line %d - -Warning: mysql_field_table(): Field -1 is invalid for MySQL result index %d in %s on line %d -unicode(4) "test" +%unicode|string%(4) "test" Warning: mysql_field_table(): Field 2 is invalid for MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_field_type.phpt b/ext/mysql/tests/mysql_field_type.phpt index 2a72e2de8..c737b4e3f 100644 --- a/ext/mysql/tests/mysql_field_type.phpt +++ b/ext/mysql/tests/mysql_field_type.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_field_type() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -41,22 +41,15 @@ var_dump(mysql_field_type($res, 0)); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_field_type() expects exactly 2 parameters, 1 given in %s on line %d Warning: mysql_field_type(): Field -1 is invalid for MySQL result index %d in %s on line %d -string(3) "int" - -Warning: mysql_field_type(): Field 2 is invalid for MySQL result index %d in %s on line %d - -Warning: mysql_field_type(): %d is not a valid MySQL result resource in %s on line %d -bool(false) -done! ---UEXPECTF-- -Warning: Wrong parameter count for mysql_field_type() in %s on line %d - -Warning: mysql_field_type(): Field -1 is invalid for MySQL result index %d in %s on line %d -unicode(3) "int" +%unicode|string%(3) "int" Warning: mysql_field_type(): Field 2 is invalid for MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_free_result.phpt b/ext/mysql/tests/mysql_free_result.phpt index 5a02ecff3..fe132d8c2 100644 --- a/ext/mysql/tests/mysql_free_result.phpt +++ b/ext/mysql/tests/mysql_free_result.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_free_result() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -39,6 +39,10 @@ if ($tmp = sys_get_temp_dir()) { mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- bool(true) diff --git a/ext/mysql/tests/mysql_get_client_info.phpt b/ext/mysql/tests/mysql_get_client_info.phpt index 2f8c62c91..95de0ad5e 100644 --- a/ext/mysql/tests/mysql_get_client_info.phpt +++ b/ext/mysql/tests/mysql_get_client_info.phpt @@ -8,7 +8,7 @@ include "connect.inc"; if (!is_string($info = mysql_get_client_info()) || ('' === $info)) printf("[001] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); -if (ini_get('unicode.semantics') && !is_unicode($info)) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($info)) { printf("[002] Expecting Unicode!\n"); var_inspect($info); } diff --git a/ext/mysql/tests/mysql_get_host_info.phpt b/ext/mysql/tests/mysql_get_host_info.phpt index d0ee6803a..443910c31 100644 --- a/ext/mysql/tests/mysql_get_host_info.phpt +++ b/ext/mysql/tests/mysql_get_host_info.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_get_host_info() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -25,7 +25,7 @@ if ($def_info !== $info) { var_dump($info); } -if (ini_get('unicode.semantics') && !is_unicode($info)) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($info)) { printf("[005] Expecting Unicode error message!\n"); var_inspect($info); } @@ -36,5 +36,9 @@ if (!is_null($tmp = @mysql_get_host_info($link, "too many arguments"))) { print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- done! diff --git a/ext/mysql/tests/mysql_get_proto_info.phpt b/ext/mysql/tests/mysql_get_proto_info.phpt index 3dae99314..043fb6204 100644 --- a/ext/mysql/tests/mysql_get_proto_info.phpt +++ b/ext/mysql/tests/mysql_get_proto_info.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_get_proto_info() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -26,5 +26,9 @@ if (NULL !== ($tmp = @mysql_get_proto_info('too many', 'arguments'))) print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- done! diff --git a/ext/mysql/tests/mysql_get_server_info.phpt b/ext/mysql/tests/mysql_get_server_info.phpt index 83b9c35f4..e806335e2 100644 --- a/ext/mysql/tests/mysql_get_server_info.phpt +++ b/ext/mysql/tests/mysql_get_server_info.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_get_server_info() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -25,7 +25,7 @@ if ($def_info !== $info) { var_dump($info); } -if (ini_get('unicode.semantics') && !is_unicode($info)) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($info)) { printf("[005] Expecting Unicode error message!\n"); var_inspect($info); } diff --git a/ext/mysql/tests/mysql_info.phpt b/ext/mysql/tests/mysql_info.phpt index 6cb058f18..464578c8a 100644 --- a/ext/mysql/tests/mysql_info.phpt +++ b/ext/mysql/tests/mysql_info.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_info() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -16,13 +16,13 @@ if (NULL !== ($tmp = @mysql_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; -if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (100, "a")', $link)) +if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (100, 'a')", $link)) printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (false !== ($tmp = mysql_info($link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); -if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (101, "a"), (102, "b")', $link)) +if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')", $link)) printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!is_string($tmp = mysql_info($link)) || ('' == $tmp)) @@ -40,13 +40,13 @@ if (!$res = mysql_query('ALTER TABLE test MODIFY label CHAR(2)', $link)) if (!is_string($tmp = mysql_info($link)) || ('' == $tmp)) printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); -if (!$res = mysql_query('UPDATE test SET label = "b" WHERE id >= 100', $link)) +if (!$res = mysql_query("UPDATE test SET label = 'b' WHERE id >= 100", $link)) printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!is_string($tmp = mysql_info($link)) || ('' == $tmp)) printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); -if (ini_get('unicode.semantics') && !is_unicode($tmp)) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp)) { printf("[013] Expecting Unicode!\n"); var_inspect($info); } @@ -65,5 +65,9 @@ if ($def_tmp !== $tmp) { print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- done!
\ No newline at end of file diff --git a/ext/mysql/tests/mysql_insert_id.phpt b/ext/mysql/tests/mysql_insert_id.phpt index 832f370b5..678245c2c 100644 --- a/ext/mysql/tests/mysql_insert_id.phpt +++ b/ext/mysql/tests/mysql_insert_id.phpt @@ -1,9 +1,10 @@ --TEST-- mysql_insert_id() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); +require_once('skipifdefaultconnectfailure.inc'); ?> --FILE-- <?php @@ -12,8 +13,8 @@ include "connect.inc"; $tmp = NULL; $link = NULL; -if (false !== ($tmp = @mysql_insert_id())) - printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); +if (0 !== ($tmp = @mysql_insert_id())) + printf("[001] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (NULL !== ($tmp = @mysql_insert_id($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); @@ -60,6 +61,10 @@ var_dump(mysql_insert_id($link)); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_insert_id(): %d is not a valid MySQL-Link resource in %s on line %d bool(false) diff --git a/ext/mysql/tests/mysql_list_dbs.phpt b/ext/mysql/tests/mysql_list_dbs.phpt index 7c8828d7a..3e12ce550 100644 --- a/ext/mysql/tests/mysql_list_dbs.phpt +++ b/ext/mysql/tests/mysql_list_dbs.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_list_dbs() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -27,7 +27,7 @@ if (!$num = mysql_num_rows($res)) printf("[004] Empty database list? [%d] %s\n", mysql_errno($link), mysql_error($link)); $row = mysql_fetch_array($res, MYSQL_NUM); -if (ini_get('unicode.semantics') && !is_unicode($row[0])) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row[0])) { printf("[005] Check for unicode support\n"); var_inspect($row); } @@ -46,5 +46,9 @@ mysql_close($link); print "done!\n"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- done! diff --git a/ext/mysql/tests/mysql_list_fields.phpt b/ext/mysql/tests/mysql_list_fields.phpt index 87b3cf6b8..e0b3fd5e3 100644 --- a/ext/mysql/tests/mysql_list_fields.phpt +++ b/ext/mysql/tests/mysql_list_fields.phpt @@ -1,33 +1,79 @@ --TEST-- mysql_list_fields() --SKIPIF-- -<?php -require_once('skipif.inc'); -require_once('skipifconnectfailure.inc'); +<?php +require_once 'skipif.inc'; +require_once 'skipifconnectfailure.inc'; ?> --FILE-- <?php -include_once "connect.inc"; +require_once 'connect.inc'; $tmp = NULL; $link = NULL; -// This will implicitly try to connect, and we don't want it -//if (false !== ($tmp = mysql_list_fields($link, $link))) -// printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - -require('table.inc'); +require 'table.inc'; if (!$res = mysql_list_fields($db, 'test', $link)) printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); -if (!($num = mysql_num_fields($res))) - printf("[004] Empty field list? [%d] %s\n", mysql_errno($link), mysql_error($link)); +if (2 !== ($num = mysql_num_fields($res))) + printf("[004] Expecting two fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link)); + +mysql_free_result($res); + +if (!mysql_query("DROP TABLE IF EXISTS test2", $link)) + printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); + +if (!$res = @mysql_list_fields($db, 'test2', $link)) + printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); + +if (!$res = mysql_list_fields($db, 'test', $link)) + printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); + +if (2 !== ($num = mysql_num_fields($res))) + printf("[008] Expecting 2 fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link)); + +var_dump(mysql_fetch_assoc($res)); +for ($field_offset = 0; $field_offset < mysql_num_fields($res); $field_offset++) { + printf("Field Offset %d\n", $field_offset); + printf("mysql_field_flags(): %s\n", mysql_field_flags($res, $field_offset)); + printf("mysql_field_len(): %s\n", mysql_field_len($res, $field_offset)); + printf("mysql_field_name(): %s\n", mysql_field_name($res, $field_offset)); + printf("mysql_field_type(): %s\n", mysql_field_type($res, $field_offset)); +} mysql_free_result($res); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once 'connect.inc'; +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + +if (!mysql_query("DROP TABLE IF EXISTS test", $link)) + printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + +if (!mysql_query("DROP TABLE IF EXISTS test2", $link)) + printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + +mysql_close($link); +?> --EXPECTF-- +[006] [%d] %s +bool(false) +Field Offset 0 +mysql_field_flags()%s +mysql_field_len(): 11 +mysql_field_name(): id +mysql_field_type(): int +Field Offset 1 +mysql_field_flags()%s +mysql_field_len(): 1 +mysql_field_name(): label +mysql_field_type(): string done! diff --git a/ext/mysql/tests/mysql_list_processes.phpt b/ext/mysql/tests/mysql_list_processes.phpt index 9cf51db61..b0c71ad1b 100644 --- a/ext/mysql/tests/mysql_list_processes.phpt +++ b/ext/mysql/tests/mysql_list_processes.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_list_processes() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -24,7 +24,7 @@ if (!$num = mysql_num_rows($res)) printf("[003] Empty process list? [%d] %s\n", mysql_errno($link), mysql_error($link)); $row = mysql_fetch_array($res, MYSQL_NUM); -if (ini_get('unicode.semantics') && !is_unicode($row[0])) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row[0])) { printf("[004] Check for unicode support\n"); var_inspect($row); } @@ -38,7 +38,7 @@ if (!$num = mysql_num_rows($res)) printf("[006] Empty process list? [%d] %s\n", mysql_errno(), mysql_error()); $row = mysql_fetch_array($res, MYSQL_NUM); -if (ini_get('unicode.semantics') && !is_unicode($row[0])) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row[0])) { printf("[007] Check for unicode support\n"); var_inspect($row); } diff --git a/ext/mysql/tests/mysql_list_tables.phpt b/ext/mysql/tests/mysql_list_tables.phpt index 820ad378a..cf0b1a636 100644 --- a/ext/mysql/tests/mysql_list_tables.phpt +++ b/ext/mysql/tests/mysql_list_tables.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_list_tables() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -77,5 +77,9 @@ mysql_close($link); print "done!\n"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- done! diff --git a/ext/mysql/tests/mysql_max_persistent.phpt b/ext/mysql/tests/mysql_max_persistent.phpt index 498b5c5d3..ac35cd178 100644 --- a/ext/mysql/tests/mysql_max_persistent.phpt +++ b/ext/mysql/tests/mysql_max_persistent.phpt @@ -4,15 +4,9 @@ mysql_[p]connect() - max_links/max_persistent <?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); -require_once('connect.inc'); - -$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket); -if (!$link) - die("skip Cannot connect to MySQL"); +require_once('table.inc'); -mysql_close($link); - -mysqli_query('DROP USER pcontest', $link); +mysql_query('DROP USER pcontest', $link); if (!mysql_query('CREATE USER pcontest IDENTIFIED BY "pcontest"', $link)) { printf("skip Cannot create second DB user [%d] %s", mysql_errno($link), mysql_error($link)); mysql_close($link); @@ -81,6 +75,20 @@ mysql_query('DROP USER pcontest', $links[0]); mysql_close($links[0]); print "done!\n"; ?> +--CLEAN-- +<?php +// connect + select_db +require_once("connect.inc"); +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[c001] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $myhost, $user, $db, $port, $socket); +} + +@mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link); +@mysql_query('DROP USER pcontest', $link); + +mysql_close($link); +?> --EXPECTF-- Warning: mysql_pconnect(): Too many open persistent links (1) in %s on line %d [020] Cannot connect using host '%s', user '%s', password '****', [0] 0 diff --git a/ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt b/ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt new file mode 100644 index 000000000..d54cb5070 --- /dev/null +++ b/ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt @@ -0,0 +1,37 @@ +--TEST-- +mysqlnd.net_read_timeout > default_socket_timeout +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +require_once('connect.inc'); +?> +--INI-- +default_socket_timeout=1 +mysqlnd.net_read_timeout=12 +max_execution_time=12 +--FILE-- +<?php + set_time_limit(12); + include ("connect.inc"); + + if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[001] Connect failed, [%d] %s\n", mysql_errno(), mysqlerror()); + } + + if (!$res = mysql_query("SELECT SLEEP(6)", $link)) + printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link)); + + var_dump(mysql_fetch_assoc($res)); + + mysql_free_result($res); + mysql_close($link); + + print "done!"; +?> +--EXPECTF-- +array(1) { + [%u|b%"SLEEP(6)"]=> + %unicode|string%(1) "0" +} +done!
\ No newline at end of file diff --git a/ext/mysql/tests/mysql_num_fields.phpt b/ext/mysql/tests/mysql_num_fields.phpt index 3ec305ea2..0dad5f771 100644 --- a/ext/mysql/tests/mysql_num_fields.phpt +++ b/ext/mysql/tests/mysql_num_fields.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_num_fields() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -47,6 +47,10 @@ mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_num_fields(): %d is not a valid MySQL result resource in %s on line %d done! diff --git a/ext/mysql/tests/mysql_num_rows.phpt b/ext/mysql/tests/mysql_num_rows.phpt index d93b4e2ff..1f68b4d60 100644 --- a/ext/mysql/tests/mysql_num_rows.phpt +++ b/ext/mysql/tests/mysql_num_rows.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_num_rows() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -57,6 +57,10 @@ if ($res = mysql_query('SELECT COUNT(id) AS num FROM test', $link)) { mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in %s on line %d diff --git a/ext/mysql/tests/mysql_pconn_disable.phpt b/ext/mysql/tests/mysql_pconn_disable.phpt index 9ec44234a..dfb04eeef 100644 --- a/ext/mysql/tests/mysql_pconn_disable.phpt +++ b/ext/mysql/tests/mysql_pconn_disable.phpt @@ -52,6 +52,10 @@ mysql.max_links=2 print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- [001] Can connect to the server. [002] Can fetch data using persistent connection! Data = '1' diff --git a/ext/mysql/tests/mysql_pconn_kill.phpt b/ext/mysql/tests/mysql_pconn_kill.phpt index df863bb79..8543e39d6 100755 --- a/ext/mysql/tests/mysql_pconn_kill.phpt +++ b/ext/mysql/tests/mysql_pconn_kill.phpt @@ -1,7 +1,7 @@ --TEST-- mysql_pconnect() - killing persitent connection --SKIPIF-- -<?php +<?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> @@ -24,7 +24,7 @@ mysql.max_persistent=2 printf("[001] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user, $db, $port, $socket); mysql_select_db($db, $plink); - + $pthread_id = mysql_thread_id($plink); $thread_id = mysql_thread_id($link); @@ -40,8 +40,8 @@ mysql.max_persistent=2 printf("[003] Cannot find regular connection thread in process list, [%d] %s\n", mysql_errno($link), mysql_error($link)); if (!isset($processlist[$pthread_id])) printf("[004] Cannot find persistent connection thread in process list, [%d] %s\n", mysql_errno($link), mysql_error($link)); - - if (!mysql_query(sprintf("KILL %d", $pthread_id), $link)) + + if (!mysql_query(sprintf("KILL %d", $pthread_id), $link)) printf("[005] Cannot kill persistent connection thread, [%d] %s\n", mysql_errno($link), mysql_error($link)); while (1) { @@ -64,7 +64,7 @@ mysql.max_persistent=2 mysql_close($plink); - if (!($plink = mysql_pconnect($myhost, $user, $passwd))) + if (!($plink = mysql_pconnect($myhost, $user, $passwd))) printf("[009] Cannot create new persistent connection, [%d] %s\n", mysql_errno(), mysql_error()); mysql_select_db($db, $plink); @@ -82,7 +82,7 @@ mysql.max_persistent=2 printf("[012] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user, $db, $port, $socket); mysql_select_db($db, $link2); - if (!mysql_query(sprintf("KILL %d", $thread_id), $link2)) + if (!mysql_query(sprintf("KILL %d", $thread_id), $link2)) printf("[013] Cannot kill regular connection thread, [%d] %s\n", mysql_errno($link2), mysql_error($link2)); if (!($link = mysql_connect($myhost, $user, $passwd, true))) @@ -101,6 +101,10 @@ mysql.max_persistent=2 mysql_close($link2); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- bool(true) done! diff --git a/ext/mysql/tests/mysql_pconn_max_links.phpt b/ext/mysql/tests/mysql_pconn_max_links.phpt index b5b0a3a56..1d39e98b4 100644 --- a/ext/mysql/tests/mysql_pconn_max_links.phpt +++ b/ext/mysql/tests/mysql_pconn_max_links.phpt @@ -4,7 +4,7 @@ Persistent connections and mysql.max_persistent <?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); - require_once('connect.inc'); + require_once('table.inc'); if ($socket) $host = sprintf("%s:%s", $host, $socket); @@ -18,26 +18,35 @@ Persistent connections and mysql.max_persistent if (!mysql_select_db($db, $link)) die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link))); + if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link)) + die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link))); + + $row = mysql_fetch_assoc($res); + mysql_free_result($res); + $host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user'])); + mysql_query('DROP USER pcontest', $link); - if (!mysql_query('CREATE USER pcontest IDENTIFIED BY "pcontest"', $link)) { + mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link); + if (!mysql_query(sprintf('CREATE USER pcontest@"%s" IDENTIFIED BY "pcontest"', mysql_real_escape_string($host, $link)), $link)) { printf("skip Cannot create second DB user [%d] %s", mysql_errno($link), mysql_error($link)); mysql_close($link); die(); } // we might be able to specify the host using CURRENT_USER(), but... - if (!mysql_query(sprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'%%'", $db), $link)) { + if (!mysql_query(sprintf('GRANT SELECT ON TABLE %s.test TO pcontest@"%s"', $db, mysql_real_escape_string($host, $link)), $link)) { printf("skip Cannot GRANT SELECT to second DB user [%d] %s", mysql_errno($link), mysql_error($link)); - mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link); - mysql_query('DROP USER pcontest', $link); + mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link); + mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link); mysql_close($link); die(); } + mysql_close($link); ?> --INI-- -mysql.max_links=2 -mysql.max_persistent=1 +mysql.max_links=3 +mysql.max_persistent=2 mysql.allow_persistent=1 --FILE-- <?php @@ -49,7 +58,7 @@ mysql.allow_persistent=1 else if ($port) $host = sprintf("%s:%s", $host, $port); - if (!$plink = mysql_pconnect($host, 'pcontest', 'pcontest')) + if (!$plink = mysql_pconnect($host, $user, $passwd)) printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n", mysql_errno(), mysql_error()); @@ -76,18 +85,26 @@ mysql.allow_persistent=1 var_dump($row); // change the password for the second DB user and kill the persistent connection - if (!mysql_query('SET PASSWORD FOR pcontest = PASSWORD("newpass")', $link)) - printf("[006] Cannot change PW of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link)); + if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link)) + printf("[006] [%d] %s", mysql_errno($link), mysql_error($link)); + + $row = mysql_fetch_assoc($res); + mysql_free_result($res); + $host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user'])); + + $sql = sprintf('SET PASSWORD FOR pcontest@"%s" = PASSWORD("newpass")', mysql_real_escape_string($host, $link)); + if (!mysql_query($sql, $link)) + printf("[007] Cannot change PW of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link)); // persistent connections cannot be closed but only be killed $pthread_id = mysql_thread_id($plink); if (!mysql_query(sprintf('KILL %d', $pthread_id), $link)) - printf("[007] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link)); + printf("[008] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link)); // give the server a second to really kill the thread sleep(1); if (!$res = mysql_query("SHOW FULL PROCESSLIST", $link)) - printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); + printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link)); $running_threads = array(); while ($row = mysql_fetch_assoc($res)) @@ -95,11 +112,11 @@ mysql.allow_persistent=1 mysql_free_result($res); if (isset($running_threads[$pthread_id])) - printf("[009] Persistent connection has not been killed"); + printf("[010] Persistent connection has not been killed\n"); // we might get the old handle if ($plink = @mysql_pconnect($host, 'pcontest', 'pcontest')) - printf("[010] Can connect using the old password, [%d] %s\n", + printf("[011] Can connect using the old password, [%d] %s\n", mysql_errno(), mysql_error()); ob_start(); @@ -108,62 +125,69 @@ mysql.allow_persistent=1 ob_end_clean(); $phpinfo = substr($phpinfo, strpos($phpinfo, 'MySQL Support => enabled'), 500); if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) - printf("[011] Cannot get # active persistent links from phpinfo()"); + printf("[012] Cannot get # active persistent links from phpinfo()\n"); $num_plinks_kill = $matches[1]; - if ($num_plinks_kill >= $num_plinks) - printf("[012] Statistics seems to be wrong, got %d active persistent links, expecting < %d links", + if ($num_plinks_kill > $num_plinks) + printf("[013] Statistics seems to be wrong, got %d active persistent links, expecting < %d links\n", $num_plinks_kill, $num_plinks); // The first connection has been closed, the last pconnect() was unable to connect -> no connection open // We must be able to connect because max_persistent limit has not been reached if (!$plink = mysql_pconnect($host, 'pcontest', 'newpass')) - printf("[013] Cannot connect using the second DB, [%d] %s\n", - mysql_errno(), mysql_error()); + die(sprintf("[014] Cannot connect using the second DB, [%d] %s\n", + mysql_errno(), mysql_error())); if (!mysql_select_db($db, $plink)) - printf("[014] [%d] %s\n", mysql_errno($plink), mysql_error($plink)); + printf("[015] [%d] %s\n", mysql_errno($plink), mysql_error($plink)); if (!$res = mysql_query('SELECT id, label FROM test WHERE id = 1', $plink)) - printf("[015] Cannot run query on persistent connection of second DB user, [%d] %s\n", + printf("[016] Cannot run query on persistent connection of second DB user, [%d] %s\n", mysql_errno($plink), mysql_error($plink)); if (!$row = mysql_fetch_assoc($res)) - printf("[016] Cannot run fetch result, [%d] %s\n", + printf("[017] Cannot run fetch result, [%d] %s\n", mysql_errno($plink), mysql_error($plink)); mysql_free_result($res); var_dump($row); - mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link); - mysql_query('DROP USER pcontest', $link); + mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link); + mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link); mysql_close($link); print "done!"; ?> ---EXPECTF-- -array(2) { - ["id"]=> - string(1) "1" - ["label"]=> - string(1) "a" -} -array(2) { - ["id"]=> - string(1) "1" - ["label"]=> - string(1) "a" +--CLEAN-- +<?php +// connect + select_db +require_once("connect.inc"); +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[c001] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $myhost, $user, $db, $port, $socket); } -done! ---UEXPECTF-- + +if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link)) + printf("[c002] [%d] %s", mysql_errno($link), mysql_error($link)); + +$row = mysql_fetch_assoc($res); +mysql_free_result($res); +$host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user'])); + +@mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link); +@mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link); + +mysql_close($link); +?> +--EXPECTF-- array(2) { - [u"id"]=> - unicode(1) "1" - [u"label"]=> - unicode(1) "a" + [%u|b%"id"]=> + %unicode|string%(1) "1" + [%u|b%"label"]=> + %unicode|string%(1) "a" } array(2) { - [u"id"]=> - unicode(1) "1" - [u"label"]=> - unicode(1) "a" + [%u|b%"id"]=> + %unicode|string%(1) "1" + [%u|b%"label"]=> + %unicode|string%(1) "a" } done! diff --git a/ext/mysql/tests/mysql_phpinfo.phpt b/ext/mysql/tests/mysql_phpinfo.phpt index 1778e48d2..a57e42e6b 100644 --- a/ext/mysql/tests/mysql_phpinfo.phpt +++ b/ext/mysql/tests/mysql_phpinfo.phpt @@ -73,4 +73,4 @@ if ($IS_MYSQLND) { print "done!"; ?> --EXPECTF-- -done!
\ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_ping.phpt b/ext/mysql/tests/mysql_ping.phpt index 2e4130e33..edf18c439 100644 --- a/ext/mysql/tests/mysql_ping.phpt +++ b/ext/mysql/tests/mysql_ping.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_ping() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -37,6 +37,10 @@ if (false !== ($tmp = mysql_ping($link))) print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- bool(true) bool(true) diff --git a/ext/mysql/tests/mysql_query.phpt b/ext/mysql/tests/mysql_query.phpt index d1d4dfb8e..a5978a6c1 100644 --- a/ext/mysql/tests/mysql_query.phpt +++ b/ext/mysql/tests/mysql_query.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_query() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -26,26 +26,26 @@ if (NULL !== ($tmp = @mysql_query("SELECT 1 AS a", $link, "foo"))) if (false !== ($tmp = mysql_query('THIS IS NOT SQL', $link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); -if (false !== ($tmp = mysql_query('SELECT "this is sql but with backslash g"\g', $link))) +if (false !== ($tmp = mysql_query("SELECT 'this is sql but with backslash g'\g", $link))) printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysql_errno($link)) || ('' == mysql_error($link))) printf("[006] mysql_errno()/mysql_error should return some error\n"); -if (!$res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; ', $link)) +if (!$res = mysql_query("SELECT 'this is sql but with semicolon' AS valid ; ", $link)) printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); -if (!$res = mysql_query('SELECT "a" AS ""', $link)) +if (!$res = mysql_query("SELECT 'a' AS ''", $link)) printf("[007a] [%d] %s\n", mysql_errno($link), mysql_error($link)); var_dump($tmp = mysql_fetch_assoc($res)); var_dump($tmp[""]); mysql_free_result($res); -if (false !== ($res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES', $link))) +if (false !== ($res = mysql_query("SELECT 'this is sql but with semicolon' AS valid ; SHOW VARIABLES", $link))) printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (mysql_query('DROP PROCEDURE IF EXISTS p', $link)) { @@ -58,7 +58,7 @@ if (mysql_query('DROP PROCEDURE IF EXISTS p', $link)) { printf("[009] Result seems wrong, dumping\n"); var_dump($tmp); } - if (ini_get('unicode.semantics') && !is_unicode($tmp['p_version'])) { + if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp['p_version'])) { printf("[010] Expecting unicode string, dumping\n"); var_dump($tmp); } @@ -75,7 +75,7 @@ if (mysql_query('DROP PROCEDURE IF EXISTS p', $link)) { printf("[012] Result seems wrong, dumping\n"); var_dump($tmp); } - if (ini_get('unicode.semantics') && !is_unicode($tmp['f_version'])) { + if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp['f_version'])) { printf("[013] Expecting unicode string, dumping\n"); var_dump($tmp); } @@ -92,29 +92,36 @@ if (false !== ($tmp = mysql_query("SELECT id FROM test", $link))) print "done!"; ?> ---EXPECTF-- -array(1) { - ["valid"]=> - string(30) "this is sql but with semicolon" +--CLEAN-- +<?php +require_once('connect.inc'); + +// connect + select_db +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[clean] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $myhost, $user, $db, $port, $socket); } -array(1) { - [""]=> - string(1) "a" + +if (!mysql_query('DROP TABLE IF EXISTS test', $link)) { + printf("[clean] Failed to drop test table: [%d] %s\n", mysql_errno($link), mysql_error($link)); } -string(1) "a" -Warning: mysql_query(): %d is not a valid MySQL-Link resource in %s on line %d -done! ---UEXPECTF-- +/* MySQL server may not support this - ignore errors */ +@mysql_query('DROP PROCEDURE IF EXISTS p', $link); +@mysql_query('DROP FUNCTION IF EXISTS f', $link); + +mysql_close($link); +?> +--EXPECTF-- array(1) { - [u"valid"]=> - unicode(30) "this is sql but with semicolon" + [%u|b%"valid"]=> + %unicode|string%(30) "this is sql but with semicolon" } array(1) { - [u""]=> - unicode(1) "a" + [%u|b%""]=> + %unicode|string%(1) "a" } -unicode(1) "a" +%unicode|string%(1) "a" Warning: mysql_query(): %d is not a valid MySQL-Link resource in %s on line %d done! diff --git a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt index 9561ece70..577ede375 100644 --- a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt +++ b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt @@ -52,7 +52,7 @@ if (file_exists('./simple.csv')) if (!$fp = fopen('./simple.csv', 'w')) printf("[003] Cannot open CSV file\n"); -if (ini_get('unicode.semantics')) { +if (version_compare(PHP_VERSION, '5.9.9', '>') >= 0) { if (!fwrite($fp, (binary)"'97';'x';\n") || !fwrite($fp, (binary)"'98';'y';\n") || !fwrite($fp, (binary)"99;'z';\n")) { diff --git a/ext/mysql/tests/mysql_real_escape_string.phpt b/ext/mysql/tests/mysql_real_escape_string.phpt index 511da068b..2789ad276 100644 --- a/ext/mysql/tests/mysql_real_escape_string.phpt +++ b/ext/mysql/tests/mysql_real_escape_string.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_real_escape_string() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -33,20 +33,11 @@ assert($tmp === mysql_real_escape_string("foo" . chr(0) . "bar")); print "done!"; ?> --EXPECTF-- -string(31) "Am I a unicode string in PHP 6?" -string(2) "\\" -string(2) "\"" -string(2) "\'" -string(2) "\n" -string(2) "\r" -string(8) "foo\0bar" +%unicode|string%(31) "Am I a unicode string in PHP 6?" +%unicode|string%(2) "\\" +%unicode|string%(2) "\"" +%unicode|string%(2) "\'" +%unicode|string%(2) "\n" +%unicode|string%(2) "\r" +%unicode|string%(8) "foo\0bar" done! ---UEXPECTF-- -unicode(31) "Am I a unicode string in PHP 6?" -unicode(2) "\\" -unicode(2) "\"" -unicode(2) "\'" -unicode(2) "\n" -unicode(2) "\r" -unicode(8) "foo\0bar" -done!
\ No newline at end of file diff --git a/ext/mysql/tests/mysql_result.phpt b/ext/mysql/tests/mysql_result.phpt index 4217b2e39..2c7c61854 100644 --- a/ext/mysql/tests/mysql_result.phpt +++ b/ext/mysql/tests/mysql_result.phpt @@ -60,6 +60,10 @@ var_dump(mysql_result($res, 0)); mysql_close($link); print "done!"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- Warning: mysql_result(): Unable to jump to row -1 on MySQL result index %d in %s on line %d bool(false) @@ -73,12 +77,12 @@ bool(false) Warning: mysql_result(): Bad column offset specified in %s on line %d bool(false) valid fields -string(1) "1" -string(1) "a" -string(1) "1" -string(1) "1" -string(1) "a" -string(1) "a" +%unicode|string%(1) "1" +%unicode|string%(1) "a" +%unicode|string%(1) "1" +%unicode|string%(1) "1" +%unicode|string%(1) "a" +%unicode|string%(1) "a" some invalid fields Warning: mysql_result(): unknown not found in MySQL result index %d in %s on line %d @@ -93,7 +97,7 @@ bool(false) Warning: mysql_result(): _test. not found in MySQL result index %d in %s on line %d bool(false) _id -string(1) "1" +%unicode|string%(1) "1" _label string(2) "aa" _foo @@ -108,51 +112,3 @@ bool(false) Warning: mysql_result(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! ---UEXPECTF-- -Warning: mysql_result(): Unable to jump to row -1 on MySQL result index %d in %s on line %d -bool(false) - -Warning: mysql_result(): Unable to jump to row 2 on MySQL result index %d in %s on line %d -bool(false) - -Warning: mysql_result(): Bad column offset specified in %s on line %d -bool(false) - -Warning: mysql_result(): Bad column offset specified in %s on line %d -bool(false) -valid fields -unicode(1) "1" -unicode(1) "a" -unicode(1) "1" -unicode(1) "1" -unicode(1) "a" -unicode(1) "a" -some invalid fields - -Warning: mysql_result(): unknown not found in MySQL result index %d in %s on line %d -bool(false) - -Warning: mysql_result(): _test. not found in MySQL result index %d in %s on line %d -bool(false) - -Warning: mysql_result(): not found in MySQL result index %d in %s on line %d -bool(false) - -Warning: mysql_result(): _test. not found in MySQL result index %d in %s on line %d -bool(false) -_id -unicode(1) "1" -_label -string(2) "aa" -_foo -NULL - -Warning: mysql_result(): test.id not found in MySQL result index %d in %s on line %d -bool(false) - -Warning: mysql_result(): test.label not found in MySQL result index %d in %s on line %d -bool(false) - -Warning: mysql_result(): %d is not a valid MySQL result resource in %s on line %d -bool(false) -done!
\ No newline at end of file diff --git a/ext/mysql/tests/mysql_select_db.phpt b/ext/mysql/tests/mysql_select_db.phpt index 3391fa6e9..211e34222 100644 --- a/ext/mysql/tests/mysql_select_db.phpt +++ b/ext/mysql/tests/mysql_select_db.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_select_db() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -66,13 +66,7 @@ if (false !== ($tmp = mysql_select_db($db, $link))) print "done!\n"; ?> --EXPECTF-- -string(%d) "%s" -bool(false) - -Warning: mysql_select_db(): %d is not a valid MySQL-Link resource in %s on line %d -done! ---UEXPECTF-- -unicode(%d) "%s" +%unicode|string%(%d) "%s" bool(false) Warning: mysql_select_db(): %d is not a valid MySQL-Link resource in %s on line %d diff --git a/ext/mysql/tests/mysql_set_charset.phpt b/ext/mysql/tests/mysql_set_charset.phpt index 0fbff44e8..953323b49 100644 --- a/ext/mysql/tests/mysql_set_charset.phpt +++ b/ext/mysql/tests/mysql_set_charset.phpt @@ -4,6 +4,11 @@ mysql_set_charset() - STUB, function usage not recommended <?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); + +if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) { + die('skip set character set not functional with PHP 6 (fomerly PHP 6 && unicode.semantics=On)'); +} + if (!function_exists('mysql_set_charset')) die("skip Function not available"); ?> @@ -33,7 +38,7 @@ if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) /* unicode mode should throw a warning */ $tmp = mysql_set_charset('uFt8', $link); -if (ini_get('unicode.semantics')) +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1)) $expect = false; else $expect = true; @@ -54,6 +59,3 @@ print "done!"; ?> --EXPECTF-- done! ---UEXPECTF-- -Warning: mysql_set_charset(): Character set %s is not supported when running PHP with unicode.semantics=On. in %s on line %d -done!
\ No newline at end of file diff --git a/ext/mysql/tests/mysql_stat.phpt b/ext/mysql/tests/mysql_stat.phpt index bc5be9540..288c53f06 100644 --- a/ext/mysql/tests/mysql_stat.phpt +++ b/ext/mysql/tests/mysql_stat.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_stat() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -25,7 +25,7 @@ if ((!is_string($stat = mysql_stat($link))) || ('' === $stat)) printf("[003] Expecting non empty string, got %s/'%s', [%d] %s\n", gettype($stat), $stat, mysql_errno($link), mysql_error($link)); -if (ini_get('unicode.semantics') && !is_unicode($stat)) { +if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($stat)) { printf("[004] Expecting Unicode error message!\n"); var_inspect($stat); } diff --git a/ext/mysql/tests/mysql_tablename.phpt b/ext/mysql/tests/mysql_tablename.phpt index 684734a7d..2415e4fda 100644 --- a/ext/mysql/tests/mysql_tablename.phpt +++ b/ext/mysql/tests/mysql_tablename.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_tablename() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -45,18 +45,7 @@ print "done!"; Warning: mysql_tablename() expects at least 2 parameters, 1 given in %s on line %d Warning: mysql_tablename(): Unable to jump to row -1 on MySQL result index %d in %s on line %d -string(1) "1" - -Warning: mysql_tablename(): Unable to jump to row 2 on MySQL result index %d in %s on line %d - -Warning: mysql_tablename(): %d is not a valid MySQL result resource in %s on line %d -bool(false) -done! ---UEXPECTF-- -Warning: Wrong parameter count for mysql_tablename() in %s on line %d - -Warning: mysql_tablename(): Unable to jump to row -1 on MySQL result index %d in %s on line %d -unicode(1) "1" +%unicode|string%(1) "1" Warning: mysql_tablename(): Unable to jump to row 2 on MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_trace_mode.phpt b/ext/mysql/tests/mysql_trace_mode.phpt index af08e68b3..622f41306 100644 --- a/ext/mysql/tests/mysql_trace_mode.phpt +++ b/ext/mysql/tests/mysql_trace_mode.phpt @@ -10,12 +10,11 @@ mysql.trace_mode=1 error_reporting=E_ALL | E_NOTICE | E_STRICT --FILE-- <?php -require_once('connect.inc'); require_once('table.inc'); $res1 = mysql_query('SELECT id FROM test', $link); -if (!$res2 = mysql_db_query('test', 'SELECT id FROM test', $link)) +if (!$res2 = mysql_db_query($db, 'SELECT id FROM test', $link)) printf("[001] [%d] %s\n", mysql_errno($link), mysql_error($link)); mysql_free_result($res2); print mysql_escape_string("I don't mind character sets, do I?\n"); @@ -25,10 +24,14 @@ mysql_close($link); print "done!\n"; ?> +--CLEAN-- +<?php +require_once("clean_table.inc"); +?> --EXPECTF-- -Deprecated: mysql_db_query(): This function is deprecated; use mysql_query() instead%sin %s on line %d +Deprecated: mysql_db_query(): %s -Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in %s on line %d +Deprecated: mysql_escape_string(): %s I don\'t mind character sets, do I?\n Warning: mysql_query(): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BOGUS_SQL' at line 1 in %s on line %d done! diff --git a/ext/mysql/tests/mysql_unbuffered_query.phpt b/ext/mysql/tests/mysql_unbuffered_query.phpt index 6701ce52a..ad9b4fbc5 100644 --- a/ext/mysql/tests/mysql_unbuffered_query.phpt +++ b/ext/mysql/tests/mysql_unbuffered_query.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_unbuffered_query() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -23,19 +23,19 @@ if (NULL !== ($tmp = @mysql_unbuffered_query("SELECT 1 AS a", $link, "foo"))) if (false !== ($tmp = mysql_unbuffered_query('THIS IS NOT SQL', $link))) printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); -if (false !== ($tmp = mysql_unbuffered_query('SELECT "this is sql but with backslash g"\g', $link))) +if (false !== ($tmp = mysql_unbuffered_query("SELECT 'this is sql but with backslash g'\g", $link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ((0 === mysql_errno($link)) || ('' == mysql_error($link))) printf("[005] mysql_errno()/mysql_error should return some error\n"); -if (!$res = mysql_unbuffered_query('SELECT "this is sql but with semicolon" AS valid ; ', $link)) +if (!$res = mysql_unbuffered_query("SELECT 'this is sql but with semicolon' AS valid ; ", $link)) printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); var_dump(mysql_fetch_assoc($res)); mysql_free_result($res); -if (false !== ($res = mysql_unbuffered_query('SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES', $link))) +if (false !== ($res = mysql_unbuffered_query("SELECT 'this is sql but with semicolon' AS valid ; SHOW VARIABLES", $link))) printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); if (mysql_unbuffered_query('DROP PROCEDURE IF EXISTS p', $link)) { @@ -48,7 +48,7 @@ if (mysql_unbuffered_query('DROP PROCEDURE IF EXISTS p', $link)) { printf("[008] Result seems wrong, dumping\n"); var_dump($tmp); } - if (ini_get('unicode.semantics') && !is_unicode($tmp['p_version'])) { + if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp['p_version'])) { printf("[009] Expecting unicode string, dumping\n"); var_dump($tmp); } @@ -65,7 +65,7 @@ if (mysql_unbuffered_query('DROP PROCEDURE IF EXISTS p', $link)) { printf("[011] Result seems wrong, dumping\n"); var_dump($tmp); } - if (ini_get('unicode.semantics') && !is_unicode($tmp['f_version'])) { + if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp['f_version'])) { printf("[012] Expecting unicode string, dumping\n"); var_dump($tmp); } @@ -86,23 +86,30 @@ if (false !== ($tmp = mysql_unbuffered_query("SELECT id FROM test", $link))) print "done!"; ?> ---EXPECTF-- -array(1) { - ["valid"]=> - string(30) "this is sql but with semicolon" +--CLEAN-- +<?php +require_once('connect.inc'); + +// connect + select_db +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[clean] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $myhost, $user, $db, $port, $socket); } -bool(true) -resource(%d) of type (mysql result) -int(0) -Notice: mysql_close(): Function called without first fetching all rows from a previous unbuffered query in %s on line %d +if (!mysql_query('DROP TABLE IF EXISTS test', $link)) { + printf("[clean] Failed to drop test table: [%d] %s\n", mysql_errno($link), mysql_error($link)); +} -Warning: mysql_unbuffered_query(): %d is not a valid MySQL-Link resource in %s on line %d -done! ---UEXPECTF-- +/* MySQL server may not support this - ignore errors */ +@mysql_query('DROP PROCEDURE IF EXISTS p', $link); +@mysql_query('DROP FUNCTION IF EXISTS f', $link); + +mysql_close($link); +?> +--EXPECTF-- array(1) { - [u"valid"]=> - unicode(30) "this is sql but with semicolon" + [%u|b%"valid"]=> + %unicode|string%(30) "this is sql but with semicolon" } bool(true) resource(%d) of type (mysql result) diff --git a/ext/mysql/tests/skipifconnectfailure.inc b/ext/mysql/tests/skipifconnectfailure.inc index e586a33f3..a57c7dbd5 100755 --- a/ext/mysql/tests/skipifconnectfailure.inc +++ b/ext/mysql/tests/skipifconnectfailure.inc @@ -6,7 +6,7 @@ if ($skip_on_connect_failure) { else if ($port) $myhost = sprintf("%s:%s", $host, $port); - if (!$link = @mysql_connect($myhost, $user, $passwd, true)) + if (!$link = @mysql_connect($myhost, $user, $passwd, true, $connect_flags)) die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysql_errno(), mysql_error())); if (!@mysql_select_db($db, $link)) diff --git a/ext/mysql/tests/skipifdefaultconnectfailure.inc b/ext/mysql/tests/skipifdefaultconnectfailure.inc new file mode 100755 index 000000000..99f390515 --- /dev/null +++ b/ext/mysql/tests/skipifdefaultconnectfailure.inc @@ -0,0 +1,11 @@ +<?php +if ($skip_on_connect_failure) { + if (!$link = @mysql_connect()) + die(sprintf("skip Can't connect to MySQL Server with default credentials - [%d] %s", mysql_errno(), mysql_error())); + + if (!@mysql_select_db($db, $link)) + die(sprintf("skip Can't connect to MySQL Server with default credentials - [%d] %s", mysql_errno(), mysql_error())); + + mysql_close($link); +} +?> diff --git a/ext/mysql/tests/table.inc b/ext/mysql/tests/table.inc index ddfbe430c..18c858d91 100644 --- a/ext/mysql/tests/table.inc +++ b/ext/mysql/tests/table.inc @@ -1,5 +1,5 @@ <?PHP -require_once('connect.inc'); +require_once 'connect.inc'; // connect + select_db if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { @@ -18,7 +18,7 @@ if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGI exit(1); } -if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")', $link)) { +if (!mysql_query("INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')", $link)) { printf("[%d] %s\n", mysql_errno($link), mysql_error($link)); } -?>
\ No newline at end of file +?> |