cvs: php-src(PHP_5_3) /ext/mysqli/tests mysqli_affected_rows.phpt mysqli_affected_rows_oo.phpt mysqli_autocommit.phpt mysqli_autocommit_oo.phpt
mysqli_change_user.phpt mysqli_change_user_get_lock.phpt mysqli_change_user_insert_id.phpt mysqli_change_user_locks_temporary.phpt
mysqli_change_user_oo.phpt mysqli_change_user_prepared_statements.phpt mysqli_change_user_rollback.phpt mysqli_change_user_set_names.phpt
mysqli_character_set.phpt mysqli_character_set_name.phpt mysqli_character_set_name_oo.phpt mysqli_class_mysqli_driver_interface.phpt
mysqli_class_mysqli_driver_reflection.phpt mysqli_class_mysqli_interface.phpt mysqli_class_mysqli_reflection.phpt
mysqli_class_mysqli_result_interface.phpt mysqli_class_mysqli_result_reflection.phpt mysqli_class_mysqli_stmt_interface.phpt
mysqli_class_mysqli_warning.phpt mysqli_class_mysqli_warning_reflection.phpt mysqli_close.phpt mysqli_close_oo.phpt mysqli_commit.phpt
mysqli_commit_oo.phpt mysqli_connect.phpt mysqli_connect_err! no.phpt mysqli_connect_error.phpt mysqli_connect_oo.phpt mysqli_connect_oo_defaults.phpt
mysqli_connect_oo_warnings.phpt mysqli_connect_twice.phpt mysqli_constants.phpt mysqli_constants_categories.phpt
| From: | Ulf Wendel | Date: | Wed, 10 Oct 2007 10:13:47 +0000 |
| Subject: | cvs: php-src(PHP_5_3) /ext/mysqli/tests mysqli_affected_rows.phpt mysqli_affected_rows_oo.phpt mysqli_autocommit.phpt mysqli_autocommit_oo.phpt mysqli_change_user.phpt mysqli_change_user_get_lock.phpt mysqli_change_user_insert_id.phpt mysqli_change_user_locks_temporary.phpt mysqli_change_user_oo.phpt mysqli_change_user_prepared_statements.phpt mysqli_change_user_rollback.phpt mysqli_change_user_set_names.phpt mysqli_character_set.phpt mysqli_character_set_name.phpt mysqli_character_set_name_oo.phpt mysqli_class_mysqli_driver_interface.phpt mysqli_class_mysqli_driver_reflection.phpt mysqli_class_mysqli_interface.phpt mysqli_class_mysqli_reflection.phpt mysqli_class_mysqli_result_interface.phpt mysqli_class_mysqli_result_reflection.phpt mysqli_class_mysqli_stmt_interface.phpt mysqli_class_mysqli_warning.phpt mysqli_class_mysqli_warning_reflection.phpt mysqli_close.phpt mysqli_close_oo.phpt mysqli_commit.phpt mysqli_commit_oo.phpt mysqli_connect.phpt mysqli_connect_err! no.phpt mysqli_connect_error.phpt mysqli_connect_oo.phpt mysqli_connect_oo_defaults.phpt mysqli_connect_oo_warnings.phpt mysqli_connect_twice.phpt mysqli_constants.phpt mysqli_constants_categories.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-46600@lists.php.net to get a copy of this message | ||
uw Wed Oct 10 10:13:47 2007 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/mysqli/tests mysqli_affected_rows_oo.phpt
mysqli_affected_rows.phpt
mysqli_autocommit_oo.phpt
mysqli_autocommit.phpt
mysqli_change_user_get_lock.phpt
mysqli_change_user_insert_id.phpt
mysqli_change_user_locks_temporary.phpt
mysqli_change_user_oo.phpt
mysqli_change_user.phpt
mysqli_change_user_prepared_statements.phpt
mysqli_change_user_rollback.phpt
mysqli_change_user_set_names.phpt
mysqli_character_set_name_oo.phpt
mysqli_character_set_name.phpt
mysqli_character_set.phpt
mysqli_class_mysqli_driver_interface.phpt
mysqli_class_mysqli_driver_reflection.phpt
mysqli_class_mysqli_interface.phpt
mysqli_class_mysqli_reflection.phpt
mysqli_class_mysqli_result_interface.phpt
mysqli_class_mysqli_result_reflection.phpt
mysqli_class_mysqli_stmt_interface.phpt
mysqli_class_mysqli_warning.phpt
mysqli_class_mysqli_warning_reflection.phpt
mysqli_close_oo.phpt mysqli_close.phpt
mysqli_commit_oo.phpt mysqli_commit.phpt
mysqli_connect_errno.phpt
mysqli_connect_error.phpt
mysqli_connect_oo_defaults.phpt
mysqli_connect_oo.phpt
mysqli_connect_oo_warnings.phpt
mysqli_connect.phpt
mysqli_connect_twice.phpt
mysqli_constants_categories.phpt
mysqli_constants.phpt
Log:
Adding new tests. Again, I'll commit in chunks and try to find acceptable
commit sizes.
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_affected_rows_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_affected_rows_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_affected_rows_oo.phpt --TEST-- mysqli->affected_rows --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } if (0 !== ($tmp = $mysqli->affected_rows)) printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine)) printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('INSERT INTO test(id, label) VALUES (1, "a")')) printf("[005] [%d] %s\n", $mysqli->errno, $mysqli->error); if (1 !== ($tmp = $mysqli->affected_rows)) printf("[006] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); // ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented $mysqli->query('INSERT INTO test(id, label) VALUES (1, "a")'); if (-1 !== ($tmp = $mysqli->affected_rows)) printf("[007] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); if (2 !== ($tmp = $mysqli->affected_rows)) printf("[009] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')")) printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); if (2 !== ($tmp = $mysqli->affected_rows)) printf("[011] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("INSERT IGNORE INTO test(id, label) VALUES (1, 'a')")) { printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); } if (1 !== ($tmp = $mysqli->affected_rows)) printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("INSERT INTO test(id, label) SELECT id + 10, label FROM test")) printf("[014] [%d] %s\n", $mysqli->errno, $mysqli->error); if (4 !== ($tmp = $mysqli->affected_rows)) printf("[015] Expecting int/4, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("REPLACE INTO test(id, label) values (4, 'd')")) printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); if (2 !== ($tmp = $mysqli->affected_rows)) printf("[016] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("REPLACE INTO test(id, label) values (5, 'e')")) printf("[017] [%d] %s\n", $mysqli->errno, $mysqli->error); if (1 !== ($tmp = $mysqli->affected_rows)) printf("[018] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 2")) printf("[019] [%d] %s\n", $mysqli->errno, $mysqli->error); if (1 !== ($tmp = $mysqli->affected_rows)) printf("[020] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 2")) { printf("[021] [%d] %s\n", $mysqli->errno, $mysqli->error); } if (0 !== ($tmp = $mysqli->affected_rows)) printf("[022] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 100")) { printf("[023] [%d] %s\n", $mysqli->errno, $mysqli->error); } if (0 !== ($tmp = $mysqli->affected_rows)) printf("[024] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->affected_rows)) printf("[026] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_affected_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_affected_rows.phpt +++ php-src/ext/mysqli/tests/mysqli_affected_rows.phpt --TEST-- mysqli_affected_rows() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_affected_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_affected_rows($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_affected_rows($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (0 !== ($tmp = mysqli_affected_rows($link))) printf("[005] Expecting int/0, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine)) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'INSERT INTO test(id, label) VALUES (1, "a")')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (1 !== ($tmp = mysqli_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 mysqli_query($link, 'INSERT INTO test(id, label) VALUES (1, "a")'); if (-1 !== ($tmp = mysqli_affected_rows($link))) printf("[011] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4')) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (2 !== ($tmp = mysqli_affected_rows($link))) printf("[013] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')")) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (2 !== ($tmp = mysqli_affected_rows($link))) printf("[015] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT IGNORE INTO test(id, label) VALUES (1, 'a')")) { printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (1 !== ($tmp = mysqli_affected_rows($link))) printf("[017] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT INTO test(id, label) SELECT id + 10, label FROM test")) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (4 !== ($tmp = mysqli_affected_rows($link))) printf("[019] Expecting int/4, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "REPLACE INTO test(id, label) values (4, 'd')")) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (2 !== ($tmp = mysqli_affected_rows($link))) printf("[021] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "REPLACE INTO test(id, label) values (5, 'e')")) printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (1 !== ($tmp = mysqli_affected_rows($link))) printf("[023] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 2")) printf("[024] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (1 !== ($tmp = mysqli_affected_rows($link))) printf("[025] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); $charsets = array('utf8'); foreach ($charsets as $k => $charset) { if (!($res = mysqli_query($link, sprintf('SHOW CHARACTER SET LIKE "%s"', $charset)))) continue; mysqli_free_result($res); if (true !== ($tmp = mysqli_set_charset($link, $charset))) printf("[026] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (0 !== ($tmp = mysqli_affected_rows($link))) printf("[027] Expecting int/0 got %s/%s\n", gettype($tmp), $tmp); } if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 2")) { printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_affected_rows($link))) printf("[029] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 100")) { printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_affected_rows($link))) printf("[031] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = @mysqli_affected_rows($link))) printf("[033] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt --TEST-- mysqli->autocommit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { printf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); exit(1); } if (!$res = $mysqli->query("SHOW VARIABLES LIKE 'have_innodb'")) { printf("skip Cannot fetch have_innodb variable\n"); exit(1); } $row = $res->fetch_row(); $res->free_result(); $mysqli->close(); if ($row[1] == "DISABLED" || $row[1] == "NO") { printf ("skip Innodb support is not installed or enabled."); exit(1); } ?> --FILE-- <?php include "connect.inc"; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } if (!is_bool($tmp = $mysqli->autocommit(true))) printf("[002] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('SET AUTOCOMMIT = 0')) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if ($tmp['auto_commit']) printf("[005] Cannot turn off autocommit\n"); if (true !== ($tmp = $mysqli->autocommit( true))) printf("[006] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) printf("[007] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (!$tmp['auto_commit']) printf("[008] Cannot turn on autocommit\n"); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { printf("[010] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); } if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('ROLLBACK')) printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); if ((!$tmp = $res->fetch_assoc()) || (1 != $tmp['num'])) printf("[014] Expecting 1 row in table test, found %d rows. [%d] %s\n", $tmp['num'], $mysqli->errno, $mysqli->error); $res->free_result(); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('SET AUTOCOMMIT = 1')) printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) printf("[017] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (!$tmp['auto_commit']) printf("[018] Cannot turn on autocommit\n"); if (true !== ($tmp = $mysqli->autocommit( false))) printf("[019] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { printf("[020] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); } if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[021] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('ROLLBACK')) printf("[022] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[023] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); if (0 != $tmp['num']) printf("[24] Expecting 0 rows in table test, found %d rows\n", $tmp['num']); $res->free_result(); if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('COMMIT')) printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[027] [%d] %s\n", $mysqli->errno, $mysqli->error); if ((!$tmp = $res->fetch_assoc()) || (1 != $tmp['num'])) printf("[028] Expecting 1 row in table test, found %d rows. [%d] %s\n", $tmp['num'], $mysqli->errno, $mysqli->error); $res->free_result(); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[029] [%d] %s\n", $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->autocommit( false))) printf("[030] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_autocommit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_autocommit.phpt +++ php-src/ext/mysqli/tests/mysqli_autocommit.phpt --TEST-- mysqli_autocommit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); exit(1); } if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) { printf("skip Cannot fetch have_innodb variable\n"); exit(1); } $row = mysqli_fetch_row($res); mysqli_free_result($res); mysqli_close($link); if ($row[1] == "DISABLED" || $row[1] == "NO") { printf ("skip Innodb support is not installed or enabled."); exit(1); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_autocommit())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_autocommit($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_autocommit($link, $link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } if (!is_bool($tmp = mysqli_autocommit($link, true))) printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'SET AUTOCOMMIT = 0')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT @@autocommit as auto_commit')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if ($tmp['auto_commit']) printf("[008] Cannot turn off autocommit\n"); if (true !== ($tmp = mysqli_autocommit($link, true))) printf("[009] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT @@autocommit as auto_commit')) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$tmp['auto_commit']) printf("[011] Cannot turn on autocommit\n"); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) { printf("[013] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'ROLLBACK')) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ((!$tmp = mysqli_fetch_assoc($res)) || (1 != $tmp['num'])) printf("[17] Expecting 1 row in table test, found %d rows. [%d] %s\n", $tmp['num'], mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'SET AUTOCOMMIT = 1')) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT @@autocommit as auto_commit')) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$tmp['auto_commit']) printf("[021] Cannot turn on autocommit\n"); if (true !== ($tmp = mysqli_autocommit($link, false))) printf("[022] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) { printf("[023] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[024] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'ROLLBACK')) printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (0 != $tmp['num']) printf("[27] Expecting 0 rows in table test, found %d rows\n", $tmp['num']); mysqli_free_result($res); if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'COMMIT')) printf("[029] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ((!$tmp = mysqli_fetch_assoc($res)) || (1 != $tmp['num'])) printf("[31] Expecting 1 row in table test, found %d rows. [%d] %s\n", $tmp['num'], mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = @mysqli_autocommit($link, false))) printf("[033] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_get_lock.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_get_lock.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_get_lock.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_insert_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_insert_id.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_insert_id.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt --TEST-- mysqli->change_user() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('table.inc'); if (!$IS_MYSQLND && (mysqli_get_server_version($link) < 50118 && mysqli_get_server_version($link) > 50100)) { die("skip Your MySQL Server version has a known but that will cause a crash"); } ?> --FILE-- <?php include_once("connect.inc"); $link = NULL; $tmp = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->change_user())) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user . '_unknown_really', $passwd . 'non_empty', $db))) printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user, $passwd . '_unknown_really', $db))) printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user, $passwd, $db . '_unknown_really'))) printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('SET @mysqli_change_user_test_var=1')) printf("[009] Failed to set test variable: [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (1 != $tmp['test_var']) printf("[011] Cannot set test variable\n"); if (true !== ($tmp = $mysqli->change_user($user, $passwd, $db))) printf("[012] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT database() AS dbname, user() AS user')) printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (substr($tmp['user'], 0, strlen($user)) !== $user) printf("[014] Expecting user %s, got user() %s\n", $user, $tmp['user']); if ($tmp['dbname'] != $db) printf("[015] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (NULL !== $tmp['test_var']) printf("[017] Test variable is still set!\n"); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->change_user($user, $passwd, $db))) printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user.phpt --TEST-- mysqli_change_user() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_change_user())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (false !== ($tmp = mysqli_change_user($link, $user . '_unknown_really', $passwd . 'non_empty', $db))) printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_change_user($link, $user, $passwd . '_unknown_really', $db))) printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_change_user($link, $user, $passwd, $db . '_unknown_really'))) printf("[009] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'SET @mysqli_change_user_test_var=1')) printf("[010] Failed to set test variable: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (1 != $tmp['test_var']) printf("[012] Cannot set test variable\n"); if (true !== ($tmp = mysqli_change_user($link, $user, $passwd, $db))) printf("[013] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT database() AS dbname, user() AS user')) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (substr($tmp['user'], 0, strlen($user)) !== $user) printf("[015] Expecting user %s, got user() %s\n", $user, $tmp['user']); if ($tmp['dbname'] != $db) printf("[016] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (NULL !== $tmp['test_var']) printf("[019] Test variable is still set!\n"); mysqli_close($link); if (NULL !== ($tmp = @mysqli_change_user($link, $user, $passwd, $db))) printf("[020] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_rollback.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_rollback.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_rollback.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_set_names.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_set_names.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_set_names.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt --TEST-- mysqli_chararcter_set_name(), mysql_client_encoding() [alias] --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->character_set_name($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT version() AS server_version')) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[007] Need MySQL Server 4.1+ for the test!\n"); if (!$res = $mysqli->query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (!$tmp['charset']) printf("[009] Cannot determine current character set and collation\n"); $charset = $mysqli->character_set_name(); if ($tmp['charset'] !== $charset) { if ($tmp['collation'] === $charset) { printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", $tmp['collation'], $tmp['charset'], gettype($charset), $charset); } else { printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); } } $charset2 = $mysqli->character_set_name(); if ($charset2 !== $charset) { printf("[012] Alias mysqli_client_encoding returned %s/%s, expected %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset); } $mysqli->close(); if (NULL !== ($tmp = @$mysqli->character_set_name())) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (!is_null($tmp = @$mysqli->client_encoding())) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set_name.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set_name.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set_name.phpt --TEST-- mysqli_chararcter_set_name(), mysql_client_encoding() [alias] --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_character_set_name())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_character_set_name($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_character_set_name($link, $link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[007] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$tmp['charset']) printf("[009] Cannot determine current character set and collation\n"); $charset = mysqli_character_set_name($link); if ($tmp['charset'] !== $charset) { if ($tmp['collation'] === $charset) { printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", $tmp['collation'], $tmp['charset'], gettype($charset), $charset); } else { printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); } } $charset2 = mysqli_client_encoding($link); if ($charset2 !== $charset) { printf("[012] Alias mysqli_client_encoding returned %s/%s, expected %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset); } mysqli_close($link); if (NULL !== ($tmp = @mysqli_character_set_name($link))) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (!is_null($tmp = @mysqli_client_encoding())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set.phpt --TEST-- Fetching results from tables of different charsets. --SKIPIF-- <?php require_once('skipifunicode.inc'); ?> <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (ini_get("unicode.semantics")){ die('done!'); } if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[003] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[004] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, "SHOW CHARACTER SET")) printf("[005] Cannot get list of available character sets, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $charsets = array(); while ($row = mysqli_fetch_assoc($res)) $charsets[] = $row; mysqli_free_result($res); foreach ($charsets as $k => $charset) { /* The server currently 17.07.2007 can't handle data sent in ucs2 */ if ($charset['Charset'] == 'ucs2') { continue; } if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[006 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); $sql = sprintf("CREATE TABLE test(id INT, label CHAR(1)) CHARACTER SET '%s' ", $charset['Charset']); if (!mysqli_query($link, $sql)) { printf("[007 + %d] %s [%d] %s\n", $k, $sql, mysqli_errno($link), mysqli_error($link)); continue; } if (!mysqli_set_charset($link, $charset['Charset'])) { printf("[008 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); continue; } for ($i = 1; $i <= 3; $i++) { if (!mysqli_query($link, sprintf("INSERT INTO test (id, label) VALUES (%d, '%s')", $i, mysqli_real_escape_string($link, chr(ord("a") + $i))))) { var_dump($charset['Charset']); printf("[009 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); continue; } } if (!$res = mysqli_query($link, "SELECT id, label FROM test")) printf("[010 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); for ($i = 1; $i <= 3; $i++) { if (!$tmp = mysqli_fetch_assoc($res)) printf("[011 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); if ($tmp['id'] != $i) printf("[012 + %d] Expecting %d, got %s, [%d] %s\n", $k, $i, $tmp['id'], mysqli_errno($link), mysqli_error($link)); if ($tmp['label'] != chr(ord("a") + $i)) printf("[013 + %d] Expecting %d, got %s, [%d] %s\n", $k, chr(ord("a") + $i), $tmp['label'], mysqli_errno($link), mysqli_error($link)); } mysqli_free_result($res); } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt --TEST-- Interface of the class mysqli_driver --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); require('table.inc'); $driver = new mysqli_driver(); printf("Parent class:\n"); var_dump(get_parent_class($driver)); printf("\nMethods:\n"); $methods = get_class_methods($driver); $expected_methods = array(); if (!$IS_MYSQLND) { /* libmysql only */ $expected_methods = array_merge($expected_methods, array( 'embedded_server_start' => true, 'embedded_server_end' => true, )); } foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($expected_methods[$method]); unset($methods[$k]); } } if (!empty($expected_methods)) { printf("Dumping list of missing methods.\n"); var_dump($expected_methods); } if (!empty($methods)) { printf("Dumping list of unexpected methods.\n"); var_dump($methods); } if (empty($expected_methods) && empty($methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($driver)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($driver); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert(mysqli_get_client_info() === $driver->client_info); printf("driver->client_info = '%s'\n", $driver->client_info); assert(mysqli_get_client_version() === $driver->client_version); printf("driver->client_version = '%s'\n", $driver->client_version); assert($driver->driver_version > 0); printf("driver->driver_version = '%s'\n", $driver->driver_version); assert(in_array($driver->report_mode, array( MYSQLI_REPORT_ALL, MYSQLI_REPORT_STRICT, MYSQLI_REPORT_ERROR, MYSQLI_REPORT_INDEX, MYSQLI_REPORT_OFF ) )); printf("driver->report_mode = '%s'\n", $driver->report_mode); $driver->report_mode = MYSQLI_REPORT_STRICT; assert($driver->report_mode === MYSQLI_REPORT_STRICT); assert(is_bool($driver->embedded)); printf("driver->embedded = '%s'\n", $driver->embedded); printf("driver->reconnect = '%s'\n", $driver->reconnect); printf("\nAccess to undefined properties:\n"); printf("driver->unknown = '%s'\n", @$driver->unknown); print "done!"; ?> --EXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: driver->client_info = '%s' driver->client_version = '%d' driver->driver_version = '%d' driver->report_mode = '%d' driver->embedded = '' driver->reconnect = '' Access to undefined properties: driver->unknown = '' done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt --TEST-- Interface of the class mysqli_driver - Reflection --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (($tmp = substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.'))) && ($tmp < 5)) die("skip Reflection not available before PHP 5 (found PHP $tmp)"); /* Let's not deal with cross-version issues in the EXPECTF/UEXPECTF. Most of the things which we test are covered by mysqli_class_*_interface.phpt. Those tests go into the details and are aimed to be a development tool, no more. */ if (!$IS_MYSQLND) die("skip Test has been written for the latest version of mysqlnd only"); if ($MYSQLND_VERSION < 576) die("skip Test requires mysqlnd Revision 576 or newer"); ?> --FILE-- <?php require_once('reflection_tools.inc'); $class = new ReflectionClass('mysqli_driver'); inspectClass($class); print "done!"; ?> --EXPECTF-- Inspecting class 'mysqli_driver' isInternal: yes isUserDefined: no isInstantiable: yes isInterface: no isAbstract: no isFinal: yes isIteratable: no Modifiers: '%d' Parent Class: '' Extension: 'mysqli' done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt --TEST-- Interface of the class mysqli --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); printf("Parent class:\n"); var_dump(get_parent_class($mysqli)); printf("\nMethods:\n"); $methods = get_class_methods($mysqli); $expected_methods = array( 'autocommit' => true, 'change_user' => true, 'character_set_name' => true, 'client_encoding' => true, 'close' => true, 'commit' => true, 'connect' => true, 'dump_debug_info' => true, 'escape_string' => true, 'get_charset' => true, 'get_client_info' => true, 'get_server_info' => true, 'get_warnings' => true, 'init' => true, 'kill' => true, 'more_results' => true, 'multi_query' => true, 'mysqli' => true, 'next_result' => true, 'options' => true, 'ping' => true, 'prepare' => true, 'query' => true, 'real_connect' => true, 'real_escape_string' => true, 'real_query' => true, 'rollback' => true, 'select_db' => true, 'set_charset' => true, 'set_local_infile_default' => true, 'set_local_infile_handler' => true, 'set_opt' => true, 'stat' => true, 'stmt_init' => true, 'store_result' => true, 'thread_safe' => true, 'use_result' => true, ); if ($IS_MYSQLND) { // mysqlnd only /* $expected_methods['get_cache_stats'] = true; */ /* $expected_methods['get_client_stats'] = true; */ $expected_methods['get_connection_stats'] = true; } else { // libmysql only if (function_exists('mysqli_disable_reads_from_master')) $expected_methods['disable_reads_from_master'] = true; if (function_exists('mysqli_disable_rpl_parse')) $expected_methods['disable_rpl_parse'] = true; if (function_exists('mysqli_enable_reads_from_master')) $expected_methods['enable_reads_from_master'] = true; if (function_exists('mysqli_enable_rpl_parse')) $expected_methods['enable_rpl_parse'] = true; if (function_exists('mysqli_master_query')) $expected_methods['master_query'] = true; if (function_exists('mysqli_rpl_parse_enabled')) $expected_methods['rpl_parse_enabled'] = true; if (function_exists('mysqli_rpl_probe')) $expected_methods['rpl_probe'] = true; if (function_exists('mysqli_rpl_query_type')) $expected_methods['rpl_query_type'] = true; if (function_exists('mysqli_slave_query')) $expected_methods['slave_query'] = true; if (function_exists('mysqli_ssl_set')) $expected_methods['ssl_set'] = true; } /* we should add ruled when to expect them */ if (function_exists('mysqli_debug')) $expected_methods['debug'] = true; if (function_exists('ssl_set')) $expected_methods['ssl_set'] = true; foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($methods[$k]); unset($expected_methods[$method]); } } if (!empty($methods)) { printf("Dumping list of unexpected methods.\n"); var_dump($methods); } if (!empty($expected_methods)) { printf("Dumping list of missing methods.\n"); var_dump($expected_methods); } if (empty($methods) && empty($expected_methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($mysqli)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($mysqli); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert(mysqli_affected_rows($link) === $mysqli->affected_rows); printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n", $mysqli->affected_rows, gettype($mysqli->affected_rows), mysqli_affected_rows($link), gettype(mysqli_affected_rows($link))); assert(mysqli_get_client_info() === $mysqli->client_info); printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n", $mysqli->client_info, gettype($mysqli->client_info), mysqli_get_client_info(), gettype(mysqli_get_client_info())); assert(mysqli_get_client_version() === $mysqli->client_version); printf("mysqli->client_version = '%s'/%s ('%s'/%s)\n", $mysqli->client_version, gettype($mysqli->client_version), mysqli_get_client_version(), gettype(mysqli_get_client_version())); assert(mysqli_errno($link) === $mysqli->errno); printf("mysqli->errno = '%s'/%s ('%s'/%s)\n", $mysqli->errno, gettype($mysqli->errno), mysqli_errno($link), gettype(mysqli_errno($link))); assert(mysqli_error($link) === $mysqli->error); printf("mysqli->error = '%s'/%s ('%s'/%s)\n", $mysqli->error, gettype($mysqli->error), mysqli_error($link), gettype(mysqli_error($link))); assert(mysqli_field_count($link) === $mysqli->field_count); printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n", $mysqli->field_count, gettype($mysqli->field_count), mysqli_field_count($link), gettype(mysqli_field_count($link))); assert(mysqli_insert_id($link) === $mysqli->insert_id); printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n", $mysqli->insert_id, gettype($mysqli->insert_id), mysqli_insert_id($link), gettype(mysqli_insert_id($link))); assert(mysqli_sqlstate($link) === $mysqli->sqlstate); printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n", $mysqli->sqlstate, gettype($mysqli->sqlstate), mysqli_sqlstate($link), gettype(mysqli_sqlstate($link))); assert(mysqli_get_host_info($link) === $mysqli->host_info); printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n", $mysqli->host_info, gettype($mysqli->host_info), mysqli_get_host_info($link), gettype(mysqli_get_host_info($link))); /* note that the data types are different */ assert(mysqli_info($link) == $mysqli->info); printf("mysqli->info = '%s'/%s ('%s'/%s)\n", $mysqli->info, gettype($mysqli->info), mysqli_info($link), gettype(mysqli_info($link))); assert(mysqli_thread_id($link) > $mysqli->thread_id); assert(gettype($mysqli->thread_id) == gettype(mysqli_thread_id($link))); printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n", $mysqli->thread_id, gettype($mysqli->thread_id), mysqli_thread_id($link), gettype(mysqli_thread_id($link))); assert(mysqli_get_proto_info($link) === $mysqli->protocol_version); printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n", $mysqli->protocol_version, gettype($mysqli->protocol_version), mysqli_get_proto_info($link), gettype(mysqli_get_proto_info($link))); assert(mysqli_get_server_info($link) === $mysqli->server_info); printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n", $mysqli->server_info, gettype($mysqli->server_info), mysqli_get_server_info($link), gettype(mysqli_get_server_info($link))); assert(mysqli_get_server_version($link) === $mysqli->server_version); printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n", $mysqli->server_version, gettype($mysqli->server_version), mysqli_get_server_version($link), gettype(mysqli_get_server_version($link))); assert(mysqli_warning_count($link) === $mysqli->warning_count); printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n", $mysqli->warning_count, gettype($mysqli->warning_count), mysqli_warning_count($link), gettype(mysqli_warning_count($link))); printf("\nAccess to undefined properties:\n"); printf("mysqli->unknown = '%s'\n", @$mysqli->unknown); @$mysqli->unknown = 13; printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); $unknown = 'friday'; @$mysqli->unknown = $unknown; printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n"); assert(mysqli_connect_error() === $mysqli->connect_error); printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", $mysqli->connect_error, gettype($mysqli->connect_error), mysqli_connect_error(), gettype(mysqli_connect_error())); assert(mysqli_connect_errno() === $mysqli->connect_errno); printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", $mysqli->connect_errno, gettype($mysqli->connect_errno), mysqli_connect_errno(), gettype(mysqli_connect_errno())); print "done!"; ?> --EXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: mysqli->affected_rows = '%s'/integer ('%s'/integer) mysqli->client_info = '%s'/string ('%s'/string) mysqli->client_version = '%d'/integer ('%d'/integer) mysqli->errno = '0'/integer ('0'/integer) mysqli->error = ''/string (''/string) mysqli->field_count = '0'/integer ('0'/integer) mysqli->insert_id = '0'/integer ('0'/integer) mysqli->sqlstate = '00000'/string ('00000'/string) mysqli->host_info = '%s'/string ('%s'/string) mysqli->info = ''/NULL (''/string) mysqli->thread_id = '%d'/integer ('%d'/integer) mysqli->protocol_version = '%d'/integer ('%d'/integer) mysqli->server_info = '%s'/string ('%s'/string) mysqli->server_version = '%d'/integer ('%d'/integer) mysqli->warning_count = '0'/integer ('0'/integer) Access to undefined properties: mysqli->unknown = '' setting mysqli->unknown, mysqli_unknown = '13' setting mysqli->unknown, mysqli_unknown = 'friday' Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation): mysqli->connect_error = ''/string (''/string) mysqli->connect_errno = '0'/integer ('0'/integer) done! --UEXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: mysqli->affected_rows = '%s'/integer ('%s'/integer) mysqli->client_info = '%s'/unicode ('%s'/unicode) mysqli->client_version = '%d'/integer ('%d'/integer) mysqli->errno = '0'/integer ('0'/integer) mysqli->error = ''/unicode (''/unicode) mysqli->field_count = '0'/integer ('0'/integer) mysqli->insert_id = '0'/integer ('0'/integer) mysqli->sqlstate = '00000'/unicode ('00000'/unicode) mysqli->host_info = '%s'/unicode ('%s'/unicode) mysqli->info = ''/NULL (''/unicode) mysqli->thread_id = '%d'/integer ('%d'/integer) mysqli->protocol_version = '%d'/integer ('%d'/integer) mysqli->server_info = '%s'/unicode ('%s'/unicode) mysqli->server_version = '%d'/integer ('%d'/integer) mysqli->warning_count = '0'/integer ('0'/integer) Access to undefined properties: mysqli->unknown = '' setting mysqli->unknown, mysqli_unknown = '13' setting mysqli->unknown, mysqli_unknown = 'friday' Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation): mysqli->connect_error = ''/unicode (''/unicode) mysqli->connect_errno = '0'/integer ('0'/integer) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt --TEST-- Interface of the class mysqli - Reflection --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (($tmp = substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.'))) && ($tmp < 5)) die("skip Reflection not available before PHP 5 (found PHP $tmp)"); /* Let's not deal with cross-version issues in the EXPECTF/UEXPECTF. Most of the things which we test are covered by mysqli_class_*_interface.phpt. Those tests go into the details and are aimed to be a development tool, no more. */ if (!$IS_MYSQLND) die("skip Test has been written for the latest version of mysqlnd only"); if ($MYSQLND_VERSION < 576) die("skip Test requires mysqlnd Revision 576 or newer"); ?> --FILE-- <?php require_once('reflection_tools.inc'); $class = new ReflectionClass('mysqli'); inspectClass($class); print "done!"; ?> --EXPECTF-- Inspecting class 'mysqli' isInternal: yes isUserDefined: no isInstantiable: yes isInterface: no isAbstract: no isFinal: no isIteratable: no Modifiers: '0' Parent Class: '' Extension: 'mysqli' Inspecting method 'mysqli' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 8448 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'autocommit' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'change_user' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'character_set_name' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'client_encoding' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'close' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'commit' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'connect' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'debug' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'dump_debug_info' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'escape_string' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_charset' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_client_info' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_connection_stats' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_server_info' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_warnings' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'init' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'kill' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'more_results' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'multi_query' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'mysqli' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 8448 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'next_result' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'options' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'ping' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'prepare' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'query' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'real_connect' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'real_escape_string' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'real_query' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'rollback' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'select_db' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'set_charset' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'set_local_infile_default' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'set_local_infile_handler' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'set_opt' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'stat' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'stmt_init' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'store_result' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'thread_safe' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'use_result' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt --TEST-- Interface of the class mysqli_result --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); require('table.inc'); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); $mysqli_result = $mysqli->query('SELECT * FROM test'); $row = $mysqli_result->fetch_row(); $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); $res = mysqli_query($link, 'SELECT * FROM test'); assert(mysqli_fetch_row($res) === $row); printf("Parent class:\n"); var_dump(get_parent_class($mysqli_result)); printf("\nMethods:\n"); $methods = get_class_methods($mysqli_result); $expected_methods = array( '__construct' => true, 'close' => true, 'data_seek' => true, 'fetch_array' => true, 'fetch_assoc' => true, 'fetch_field' => true, 'fetch_field_direct' => true, 'fetch_fields' => true, 'fetch_object' => true, 'fetch_row' => true, 'field_seek' => true, 'free' => true, 'free_result' => true, ); if ($IS_MYSQLND) $expected_methods['fetch_all'] = true; foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($expected_methods[$method]); unset($methods[$k]); } if ($method == 'mysqli_result') { // get_class_method reports different constructor names unset($expected_methods['__construct']); unset($methods[$k]); } } if (!empty($expected_methods)) { printf("Dumping list of missing methods.\n"); var_dump($expected_methods); } if (!empty($methods)) { printf("Dumping list of unexpected methods.\n"); var_dump($methods); } if (empty($expected_methods) && empty($methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($mysqli_result)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($mysqli_result); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert(($tmp = mysqli_field_tell($res)) === $mysqli_result->current_field); printf("mysqli_result->current_field = '%s'/%s ('%s'/%s)\n", $mysqli_result->current_field, gettype($mysqli_result->current_field), $tmp, gettype($tmp)); assert(($tmp = mysqli_field_count($link)) === $mysqli_result->field_count); printf("mysqli_result->field_count = '%s'/%s ('%s'/%s)\n", $mysqli_result->field_count, gettype($mysqli_result->field_count), $tmp, gettype($tmp)); assert(($tmp = mysqli_fetch_lengths($res)) === $mysqli_result->lengths); printf("mysqli_result->lengths -> '%s'/%s ('%s'/%s)\n", ((is_array($mysqli_result->lengths)) ? implode(' ', $mysqli_result->lengths) : 'n/a'), gettype($mysqli_result->lengths), ((is_array($tmp)) ? implode(' ', $tmp) : 'n/a'), gettype($tmp)); assert(($tmp = mysqli_num_rows($res)) === $mysqli_result->num_rows); printf("mysqli_result->num_rows = '%s'/%s ('%s'/%s)\n", $mysqli_result->num_rows, gettype($mysqli_result->num_rows), $tmp, gettype($tmp)); assert(in_array($mysqli_result->type, array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT))); printf("mysqli_result->type = '%s'/%s\n", ((MYSQLI_STORE_RESULT == $mysqli_result->type) ? 'store' : 'use'), gettype($mysqli_result->type)); printf("\nAccess to undefined properties:\n"); printf("mysqli_result->unknown = '%s'\n", @$mysqli_result->unknown); printf("\nConstructor:\n"); if (!is_object($res = new mysqli_result($link))) printf("[001] Expecting object/mysqli_result got %s/%s\n", gettye($res), $res); if (null !== ($tmp = @$res->num_rows)) printf("[002] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "SELECT id FROM test ORDER BY id")) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = new mysqli_result($link))) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = new mysqli_result($link, MYSQLI_STORE_RESULT))) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = new mysqli_result($link, MYSQLI_USE_RESULT))) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = new mysqli_result($link, 'invalid'))) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT); do { $mode = mt_rand(-1000, 1000); } while (in_array($mode, $valid)); if ($TEST_EXPERIMENTAL) { ob_start(); if (!is_object($res = new mysqli_result($link, $mode))) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $content = ob_get_contents(); ob_end_clean(); if (!stristr($content, 'Invalid value for resultmode')) printf("[009] Expecting warning because of invalid resultmode\n"); } if (!is_object($res = new mysqli_result('foo'))) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = @new mysqli_result($link, MYSQLI_STORE_RESULT, 1))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); print "done!"; ?> --EXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: mysqli_result->current_field = '0'/integer ('0'/integer) mysqli_result->field_count = '2'/integer ('2'/integer) mysqli_result->lengths -> '1 1'/array ('1 1'/array) mysqli_result->num_rows = '6'/integer ('6'/integer) mysqli_result->type = 'store'/integer Access to undefined properties: mysqli_result->unknown = '' Constructor: Warning: mysqli_result::mysqli_result() expects parameter 2 to be long, string given in %s on line %d Warning: mysqli_result::mysqli_result() expects parameter 1 to be mysqli, string given in %s on line %d done! --UEXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: mysqli_result->current_field = '0'/integer ('0'/integer) mysqli_result->field_count = '2'/integer ('2'/integer) mysqli_result->lengths -> '1 1'/array ('1 1'/array) mysqli_result->num_rows = '6'/integer ('6'/integer) mysqli_result->type = 'store'/integer Access to undefined properties: mysqli_result->unknown = '' Constructor: Warning: mysqli_result::mysqli_result() expects parameter 2 to be long, Unicode string given in %s on line %d Warning: mysqli_result::mysqli_result() expects parameter 1 to be mysqli, Unicode string given in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt --TEST-- Interface of the class mysqli_result - Reflection --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (($tmp = substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.'))) && ($tmp < 5)) die("skip Reflection not available before PHP 5 (found PHP $tmp)"); /* Let's not deal with cross-version issues in the EXPECTF/UEXPECTF. Most of the things which we test are covered by mysqli_class_*_interface.phpt. Those tests go into the details and are aimed to be a development tool, no more. */ if (!$IS_MYSQLND) die("skip Test has been written for the latest version of mysqlnd only"); if ($MYSQLND_VERSION < 576) die("skip Test requires mysqlnd Revision 576 or newer"); ?> --FILE-- <?php require_once('reflection_tools.inc'); $class = new ReflectionClass('mysqli_result'); inspectClass($class); print "done!"; ?> --EXPECTF-- Inspecting class 'mysqli_result' isInternal: yes isUserDefined: no isInstantiable: yes isInterface: no isAbstract: no isFinal: no isIteratable: no Modifiers: '0' Parent Class: '' Extension: 'mysqli' Inspecting method '__construct' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method '__construct' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'close' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'data_seek' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_all' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_array' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_assoc' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_field' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_field_direct' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_fields' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_object' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_row' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'field_seek' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'free' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'free_result' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt --TEST-- Interface of the class mysqli_stmt --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); require('table.inc'); $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); $stmt = new mysqli_stmt($link); printf("Parent class:\n"); var_dump(get_parent_class($stmt)); printf("\nMethods:\n"); $methods = get_class_methods($stmt); $expected_methods = array( '__construct' => true, 'attr_get' => true, 'attr_set' => true, 'bind_param' => true, 'bind_result' => true, 'close' => true, 'data_seek' => true, 'execute' => true, 'fetch' => true, 'free_result' => true, 'get_warnings' => true, 'num_rows' => true, 'prepare' => true, 'reset' => true, 'result_metadata' => true, 'send_long_data' => true, 'stmt' => true, 'store_result' => true, ); if ($IS_MYSQLND) $expected_methods['get_result'] = true; foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($methods[$k]); unset($expected_methods[$method]); } if ($method == 'mysqli_stmt') { // get_class_method reports different constructor names unset($expected_methods['__construct']); unset($methods[$k]); } } if (!empty($methods)) { printf("More methods found than indicated. Dumping list of unexpected methods.\n"); var_dump($methods); } if (!empty($expected_methods)) { printf("Some methods are missing. Dumping list of missing methods.\n"); var_dump($expected_methods); } if (empty($methods) && empty($expected_methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($stmt)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($stmt); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert(mysqli_stmt_affected_rows($stmt) === $stmt->affected_rows); printf("stmt->affected_rows = '%s'\n", $stmt->affected_rows); if (!$stmt->prepare("INSERT INTO test(id, label) VALUES (100, 'z')") || !$stmt->execute()) printf("[001] [%d] %s\n", $stmt->errno, $stmt->error); assert(mysqli_stmt_affected_rows($stmt) === $stmt->affected_rows); printf("stmt->affected_rows = '%s'\n", $stmt->affected_rows); assert(mysqli_stmt_errno($stmt) === $stmt->errno); printf("stmt->errno = '%s'\n", $stmt->errno); assert(mysqli_stmt_error($stmt) === $stmt->error); printf("stmt->error = '%s'\n", $stmt->error); assert(mysqli_stmt_field_count($stmt) === $stmt->field_count); printf("stmt->field_count = '%s'\n", $stmt->field_count); assert($stmt->id > 0); printf("stmt->id = '%s'\n", $stmt->id); assert(mysqli_stmt_insert_id($stmt) === $stmt->insert_id); printf("stmt->insert_id = '%s'\n", $stmt->insert_id); assert(mysqli_stmt_num_rows($stmt) === $stmt->num_rows); printf("stmt->num_rows = '%s'\n", $stmt->num_rows); assert(mysqli_stmt_param_count($stmt) === $stmt->param_count); printf("stmt->param_count = '%s'\n", $stmt->param_count); assert(mysqli_stmt_sqlstate($stmt) === $stmt->sqlstate); printf("stmt->sqlstate = '%s'\n", $stmt->sqlstate); printf("\nAccess to undefined properties:\n"); printf("stmt->unknown = '%s'\n", @$stmt->unknown); @$stmt->unknown = 13; printf("stmt->unknown = '%s'\n", @$stmt->unknown); printf("\nPrepare using the constructor:\n"); $stmt = new mysqli_stmt($link, 'SELECT id FROM test ORDER BY id'); if (!$stmt->execute()) printf("[002] [%d] %s\n", $stmt->errno, $stmt->error); $stmt->close(); $obj = new stdClass(); if (!is_object($stmt = new mysqli_stmt($link, $obj))) printf("[003] Expecting NULL got %s/%s\n", gettype($stmt), $stmt); print "done!"; ?> --EXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: Warning: mysqli_stmt_affected_rows(): invalid object or resource mysqli_stmt in %s on line %d Warning: main(): Property access is not allowed yet in %s on line %d Warning: main(): Property access is not allowed yet in %s on line %d stmt->affected_rows = '' stmt->affected_rows = '1' stmt->errno = '0' stmt->error = '' stmt->field_count = '0' stmt->id = '%d' stmt->insert_id = '0' stmt->num_rows = '0' stmt->param_count = '0' stmt->sqlstate = '00000' Access to undefined properties: stmt->unknown = '' stmt->unknown = '13' Prepare using the constructor: Warning: mysqli_stmt::mysqli_stmt() expects parameter 2 to be string, object given in %s on line %d done! --UEXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: Warning: mysqli_stmt_affected_rows(): invalid object or resource mysqli_stmt in %s on line %d Warning: main(): Property access is not allowed yet in %s on line %d Warning: main(): Property access is not allowed yet in %s on line %d stmt->affected_rows = '' stmt->affected_rows = '1' stmt->errno = '0' stmt->error = '' stmt->field_count = '0' stmt->id = '%d' stmt->insert_id = '0' stmt->num_rows = '0' stmt->param_count = '0' stmt->sqlstate = '00000' Access to undefined properties: stmt->unknown = '' stmt->unknown = '13' Prepare using the constructor: Warning: mysqli_stmt::mysqli_stmt() expects parameter 2 to be binary string, object given in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt --TEST-- Interface of the class mysqli_warning - TODO --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php require('connect.inc'); $warning = new mysqli_warning(); $warning = new mysqli_warning(null); $warning = new mysqli_warning(null, null); $mysqli = new mysqli(); $warning = new mysqli_warning($mysqli); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); $stmt = new mysqli_stmt($mysqli); $warning = new mysqli_warning($stmt); $stmt = $mysqli->stmt_init(); $warning = new mysqli_warning($stmt); $obj = new stdClass(); $warning = new mysqli_warning($obj); include("table.inc"); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); $res = $mysqli->query('INSERT INTO test(id, label) VALUES (1, "zz")'); $warning = mysqli_get_warnings($mysqli); printf("Parent class:\n"); var_dump(get_parent_class($warning)); printf("\nMethods:\n"); $methods = get_class_methods($warning); $expected_methods = array( 'next' => true, ); foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($methods[$k]); unset($expected_methods[$method]); } } if (!empty($methods)) { printf("Dumping list of unexpected methods.\n"); var_dump($methods); } if (!empty($expected_methods)) { printf("Dumping list of missing methods.\n"); var_dump($expected_methods); } if (empty($methods) && empty($expected_methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($mysqli)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($mysqli); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert('' === $warning->message); printf("warning->message = '%s'\n", $warning->message); assert('' === $warning->sqlstate); printf("warning->sqlstate= '%s'\n", $warning->sqlstate); assert(0 === $warning->errno); printf("warning->errno = '%s'\n", $warning->errno); printf("\nAccess to undefined properties:\n"); printf("warning->unknown = '%s'\n", @$warning->unknown); print "done!"; ?> --EXPECTF-- Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d Warning: mysqli_warning::mysqli_warning() expects parameter 1 to be object, null given in %s on line %d Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d Warning: mysqli_warning::mysqli_warning(): Couldn't fetch mysqli in %s on line %d Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_warning::mysqli_warning(): invalid class argument in /home/nixnutz/php6_mysqlnd/ext/mysqli/tests/mysqli_class_mysqli_warning.php on line 19 Warning: mysqli_warning::mysqli_warning(): No warnings found in %s on line %d Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: warning->message = '' warning->sqlstate= '' warning->errno = '' Access to undefined properties: warning->unknown = '' done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt --TEST-- Interface of the class mysqli_stmt - Reflection --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (($tmp = substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.'))) && ($tmp < 5)) die("skip Reflection not available before PHP 5 (found PHP $tmp)"); /* Let's not deal with cross-version issues in the EXPECTF/UEXPECTF. Most of the things which we test are covered by mysqli_class_*_interface.phpt. Those tests go into the details and are aimed to be a development tool, no more. */ if (!$IS_MYSQLND) die("skip Test has been written for the latest version of mysqlnd only"); if ($MYSQLND_VERSION < 576) die("skip Test requires mysqlnd Revision 576 or newer"); ?> --FILE-- <?php require_once('reflection_tools.inc'); $class = new ReflectionClass('mysqli_warning'); inspectClass($class); print "done!"; ?> --EXPECTF-- Inspecting class 'mysqli_warning' isInternal: yes isUserDefined: no isInstantiable: no isInterface: no isAbstract: no isFinal: yes isIteratable: no Modifiers: '%d' Parent Class: '' Extension: 'mysqli' Inspecting method '__construct' isFinal: no isAbstract: no isPublic: no isPrivate: no isProtected: yes isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method '__construct' isFinal: no isAbstract: no isPublic: no isPrivate: no isProtected: yes isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'next' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_close_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_close_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_close_oo.phpt --TEST-- mysqli_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->close($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $tmp = $mysqli->close(); if (true !== $tmp) printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->close())) printf("[004] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->query("SELECT 1"))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_close.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_close.phpt +++ php-src/ext/mysqli/tests/mysqli_close.phpt --TEST-- mysqli_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_close())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_close($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); $tmp = @mysqli_close(NULL); if (NULL !== $tmp) printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); $tmp = mysqli_close($link); if (true !== $tmp) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_query($link, "SELECT 1"))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_commit_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_commit_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_commit_oo.phpt --TEST-- mysqli_commit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = $mysqli->query("SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = $res->fetch_row(); $res->free(); $mysqli->close(); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $mysqli = new mysqli(); if (!is_null($tmp = @$mysqli->commit())) printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->commit($link))) printf("[002] Expecting NULL/NULL, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); if (true !== ($tmp = $mysqli->commit())) printf("[014] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $mysqli->autocommit(false))) printf("[003] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[005] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $mysqli->commit(); if ($tmp !== true) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('ROLLBACK')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); if (1 != $tmp['num']) printf("[010] Expecting 1 row in table test, found %d rows\n", $tmp['num']); $res->free(); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->commit())) printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_commit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_commit.phpt +++ php-src/ext/mysqli/tests/mysqli_commit.phpt --TEST-- mysqli_commit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = mysqli_fetch_row($res); mysqli_free_result($res); mysqli_close($link); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf ("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_commit())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_commit($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_commit($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (true !== ($tmp = mysqli_autocommit($link, false))) printf("[005] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[007] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_commit($link); if ($tmp !== true) printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'ROLLBACK')) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (1 != $tmp['num']) printf("[12] Expecting 1 row in table test, found %d rows\n", $tmp['num']); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = @mysqli_commit($link))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_errno.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_errno.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_errno.phpt --TEST-- mysqli_connect_errno() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; // too many parameter if (0 !== ($tmp = @mysqli_connect_errno($link))) printf("[001] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (0 !== ($tmp = mysqli_connect_errno())) printf("[003] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); $link = @mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket); if (false !== $link) printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n", $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), $link); if (0 === ($tmp = mysqli_connect_errno())) printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_error.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_error.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_error.phpt --TEST-- mysqli_connect_error() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; // too many parameter if (!is_null($tmp = @mysqli_connect_error($link))) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if ('' !== ($tmp = mysqli_connect_error())) printf("[003] Expecting string/'', got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if ($link = @mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[003] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); if ('' === ($tmp = mysqli_connect_error())) printf("[004] Expecting string/'', got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt --TEST-- new mysqli() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; ini_set('mysqli.default_socket', 'socket'); ini_set('mysqli.default_port', 9999); ini_set('mysqli.default_pw', 'password'); ini_set('mysqli.default_user', 'user'); ini_set('mysqli.default_host', 'host'); mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_STRICT); ini_set('mysqli.default_socket', $socket); try { $mysqli = mysqli_init(); $mysqli->real_connect($host, $user, $passwd, $db, $port); if (!$res = $mysqli->query("SELECT 'mysqli.default_socket' AS testing")) printf("[001] [%d] %s\n", $mysqli->errno, $mysqli->error); var_dump($res->fetch_assoc()); $res->free_result(); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[002] Usage of mysqli.default_socket failed\n"); } ini_set('mysqli.default_port', $port); try { $mysqli = mysqli_init(); $mysqli->real_connect($host, $user, $passwd, $db); if (!$res = $mysqli->query("SELECT 'mysqli.default_port' AS testing")) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); var_dump($res->fetch_assoc()); $res->free_result(); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[004] Usage of mysqli.default_port failed\n"); } ini_set('mysqli.default_pw', $passwd); try { $mysqli = mysqli_init(); $mysqli->real_connect($host, $user); $mysqli->select_db($db); if (!$res = $mysqli->query("SELECT 'mysqli.default_pw' AS testing")) printf("[005] [%d] %s\n", $mysqli->errno, $mysqli->error); var_dump($res->fetch_assoc()); $res->free_result(); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[006] Usage of mysqli.default_pw failed\n"); } ini_set('mysqli.default_user', $user); try { $mysqli = mysqli_init(); $mysqli->real_connect($host); $mysqli->select_db($db); if (!$res = $mysqli->query("SELECT 'mysqli.default_user' AS testing")) printf("[007] [%d] %s\n", $mysqli->errno, $mysqli->error); var_dump($res->fetch_assoc()); $res->free_result(); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[008] Usage of mysqli.default_user failed\n"); } ini_set('mysqli.default_host', $host); try { $mysqli = mysqli_init(); $mysqli->real_connect(); $mysqli->select_db($db); if (!$res = $mysqli->query("SELECT 1")) printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); $res->free_result(); if (!$res = $mysqli->query("SELECT SUBSTRING_INDEX(USER(),'@',1) AS username")) printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if ($tmp['username'] !== $user) printf("[011] Expecting string/%s, got %s/%s\n", $user, gettype($tmp['username']), $tmp['username']); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[012] Usage of mysqli.default_host failed\n"); } try { $link = mysqli_connect($host, $user, $passwd, null, ini_get('mysqli.default_port')); mysqli_select_db($link, $db); if (!$res = mysqli_query($link, "SELECT 'have been set' AS all_defaults")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[014] Usage of mysqli_connect() has failed\n"); } try { $link = mysqli_connect($host, $user, $passwd, null); mysqli_select_db($link, $db); if (!$res = mysqli_query($link, "SELECT 'have been set' AS all_defaults")) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[016] Usage of mysqli_connect() has failed\n"); } print "done!"; ?> --EXPECTF-- array(1) { ["testing"]=> string(21) "mysqli.default_socket" } array(1) { ["testing"]=> string(19) "mysqli.default_port" } array(1) { ["testing"]=> string(17) "mysqli.default_pw" } array(1) { ["testing"]=> string(19) "mysqli.default_user" } array(1) { ["all_defaults"]=> string(13) "have been set" } array(1) { ["all_defaults"]=> string(13) "have been set" } done! --UEXPECTF-- array(1) { [u"testing"]=> unicode(21) "mysqli.default_socket" } array(1) { [u"testing"]=> unicode(19) "mysqli.default_port" } array(1) { [u"testing"]=> unicode(17) "mysqli.default_pw" } array(1) { [u"testing"]=> unicode(19) "mysqli.default_user" } array(1) { [u"all_defaults"]=> unicode(13) "have been set" } array(1) { [u"all_defaults"]=> unicode(13) "have been set" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_oo.phpt --TEST-- new mysqli() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $obj = new stdClass(); if ($mysqli = new mysqli($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket) && !mysqli_connect_errno()) printf("[003] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); if (false !== $mysqli) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($mysqli), $mysqli); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysqli.default_socket', $socket); if (!is_object($mysqli = new mysqli($host, $user, $passwd, $db, $port)) || (0 !== mysqli_connect_errno())) { printf("[005] Usage of mysqli.default_socket failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_port', $port); if (!is_object($mysqli = new mysqli($host, $user, $passwd, $db)) || (0 !== mysqli_connect_errno())) { printf("[006] Usage of mysqli.default_port failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_pw', $passwd); if (!is_object($mysqli = new mysqli($host, $user)) || (0 !== mysqli_connect_errno())) { printf("[007] Usage of mysqli.default_pw failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_user', $user); if (!is_object($mysqli = new mysqli($host)) || (0 !== mysqli_connect_errno())) { printf("[008] Usage of mysqli.default_user failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_host', $host); if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) { printf("[008] Usage of mysqli.default_host failed\n") ; } else { $mysqli->close(); } if ($IS_MYSQLND) { ini_set('mysqli.default_host', 'p:' . $host); if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) { printf("[008b] Usage of mysqli.default_host failed\n") ; } else { $mysqli->close(); } } print "... and now Exceptions\n"; mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_STRICT); try { $mysqli = new mysqli($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket); printf("[016] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); } ini_set('mysqli.default_socket', $socket); try { $mysqli = new mysqli($host, $user, $passwd, $db, $port); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[017] Usage of mysqli.default_socket failed\n") ; } ini_set('mysqli.default_port', $port); try { $mysqli = new mysqli($host, $user, $passwd, $db); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[018] Usage of mysqli.default_port failed\n") ; } ini_set('mysqli.default_pw', $passwd); try { $mysqli = new mysqli($host, $user); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[019] Usage of mysqli.default_pw failed\n"); } ini_set('mysqli.default_user', $user); try { $mysqli = new mysqli($host); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[020] Usage of mysqli.default_user failed\n") ; } ini_set('mysqli.default_host', $host); try { /* NOTE that at this point one must use a different syntax! */ $mysqli = mysqli_init(); $mysqli->real_connect(); assert(0 === mysqli_connect_errno()); $mysqli->close(); assert(0 === mysqli_connect_errno()); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[021] Usage of mysqli.default_host failed\n"); } print "done!"; ?> --EXPECTF-- Warning: mysqli::mysqli(): (%d/%d): Access denied for user '%sunknown_real'@'%s' (using password: %s) in %s on line %d Warning: mysqli::close(): Couldn't fetch mysqli in %s on line %d.... and now Exceptions Access denied for user '%s'@'%s' (using password: %s) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt --TEST-- new mysqli() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?php require_once('skipifnodefuser.inc'); if (stristr(mysqli_get_client_info(), 'mysqlnd')) die("skip: test for libmysql (different error output when using php streams"); ?> --FILE-- <?php include "connect.inc"; $myhost = 'invalidhost'; $link = NULL; print "1) bail\n"; if (!is_object($mysqli = new mysqli($myhost)) || ('mysqli' !== get_class($mysqli))) printf("[001] Expecting NULL, got %s/%s\n", gettype($mysqli), (is_object($mysqli)) ? var_export($mysqli, true) : $mysqli); print "2) be quiet\n"; if (!is_object($mysqli = @new mysqli($myhost)) || ('mysqli' !== get_class($mysqli))) printf("[002] Expecting NULL, got %s/%s\n", gettype($mysqli), (is_object($mysqli)) ? var_export($mysqli, true) : $mysqli); var_dump(mysqli_connect_error()); var_dump(mysqli_connect_errno()); print "3) bail\n"; if (false !== ($link = mysqli_connect($myhost))) { printf("[003] Expecting boolean/false, got %s/%s\n", gettype($link), $link); } print "4) be quiet\n"; if (false !== ($link = @mysqli_connect($myhost))) { printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link); } var_dump(mysqli_connect_error()); var_dump(mysqli_connect_errno()); print "done!"; ?> --EXPECTF-- 1) bail Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host '%s' (1) in %s on line %d 2) be quiet %s(%d) "Unknown MySQL server host '%s' (1)" int(2005) 3) bail Warning: mysqli_connect(): (HY000/2005): Unknown MySQL server host '%s' (1) in %s on line %d 4) be quiet %s(%d) "Unknown MySQL server host '%s' (1)" int(2005) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect.phpt +++ php-src/ext/mysqli/tests/mysqli_connect.phpt --TEST-- mysqli_connect() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; /* we need to check, if the server allows anonymous login (empty user) */ $tmp = @mysqli_connect('localhost'); $anon_allow = (gettype($tmp) == "object"); $exptype = ($anon_allow) ? "mysqli_object" : "false"; $obj = new stdClass(); if (!is_null($tmp = @mysqli_connect($obj))) printf("[001] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); $tmp = @mysqli_connect($link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[002] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[003] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[004] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link, $link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[005] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link, $link, $link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[006] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link, $link, $link, $link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[007] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[008] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); mysqli_close($link); if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[009] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); if (false !== $link) printf("[010] 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('mysqli.default_socket', $socket); if (!is_object($link = mysqli_connect($host, $user, $passwd, $db, $port))) { printf("[011] Usage of mysqli.default_socket failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_socket' AS 'testing'")) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } ini_set('mysqli.default_port', $port); if (!is_object($link = mysqli_connect($host, $user, $passwd, $db))) { printf("[013] Usage of mysqli.default_port failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_port' AS 'testing'")) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } ini_set('mysqli.default_pw', $passwd); if (!is_object($link = mysqli_connect($host, $user))) { printf("[015] Usage of mysqli.default_pw failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_pw' AS 'testing'")) printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } ini_set('mysqli.default_user', $user); if (!is_object($link = mysqli_connect($host))) { printf("[017] Usage of mysqli.default_user failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_user' AS 'testing'")) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_array($res, MYSQLI_BOTH)); mysqli_free_result($res); mysqli_close($link); } ini_set('mysqli.default_host', $host); if (!is_object($link = mysqli_connect())) { printf("[019] Usage of mysqli.default_host failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host' AS 'testing'")) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_array($res, MYSQLI_NUM)); mysqli_free_result($res); mysqli_close($link); } if ($IS_MYSQLND) { ini_set('mysqli.default_host', 'p:' . $host); if (!is_object($link = mysqli_connect())) { printf("[021] Usage of mysqli.default_host (persistent) failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { printf("[023] Result looks strange - check manually, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); mysqli_close($link); } } print "done!"; ?> --EXPECTF-- Warning: mysqli_connect(): (%d/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d array(1) { ["testing"]=> string(21) "mysqli.default_socket" } array(1) { ["testing"]=> string(19) "mysqli.default_port" } array(1) { ["testing"]=> string(17) "mysqli.default_pw" } array(2) { [0]=> string(19) "mysqli.default_user" ["testing"]=> string(19) "mysqli.default_user" } array(1) { [0]=> string(19) "mysqli.default_host" } done! --UEXPECTF-- Warning: mysqli_connect(): (%d/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d array(1) { [u"testing"]=> unicode(21) "mysqli.default_socket" } array(1) { [u"testing"]=> unicode(19) "mysqli.default_port" } array(1) { [u"testing"]=> unicode(17) "mysqli.default_pw" } array(2) { [0]=> unicode(19) "mysqli.default_user" [u"testing"]=> unicode(19) "mysqli.default_user" } array(1) { [0]=> unicode(19) "mysqli.default_host" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_twice.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_twice.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_twice.phpt --TEST-- Calling connect() on an open connection to create a new connection --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$thread_id = mysqli_thread_id($link)) printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0)) printf("[004] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); if ($thread_id == $new_thread_id) printf("[005] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) || !($row = mysqli_fetch_assoc($res))) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($row); mysqli_free_result($res); mysqli_close($link); if (!$link = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$thread_id = $link->thread_id) printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket))) printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0)) printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); if ($thread_id == $new_thread_id) printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || !($row = $res->fetch_assoc())) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($row); mysqli_free_result($res); mysqli_close($link); if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["it_works"]=> string(2) "ok" } array(1) { ["syntax"]=> string(18) "works also with oo" } done! --UEXPECTF-- array(1) { [u"it_works"]=> unicode(2) "ok" } array(1) { [u"syntax"]=> unicode(18) "works also with oo" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_constants_categories.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_constants_categories.phpt +++ php-src/ext/mysqli/tests/mysqli_constants_categories.phpt --TEST-- Constants exported by ext/mysqli - checking category - PHP bug not mysqli bug (check from time to time) --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip This hits a known PHP bug, run the test from time to time and enable it once PHP got fixed"); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $constants = get_defined_constants(true); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysqli')) { if ('mysqli' !== $group) printf("found constant '%s' in group '%s'. expecting group 'mysqli'\n", $name, $group); } } } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_constants.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_constants.phpt +++ php-src/ext/mysqli/tests/mysqli_constants.phpt --TEST-- Constants exported by ext/mysqli --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $php_version = (int)str_replace('.', '', PHP_VERSION); $constants = get_defined_constants(true); sort($constants); $expected_constants = array( 'MYSQLI_READ_DEFAULT_GROUP' => true, 'MYSQLI_READ_DEFAULT_FILE' => true, 'MYSQLI_OPT_CONNECT_TIMEOUT' => true, 'MYSQLI_OPT_LOCAL_INFILE' => true, 'MYSQLI_INIT_COMMAND' => true, 'MYSQLI_CLIENT_SSL' => true, "MYSQLI_CLIENT_COMPRESS" => true, "MYSQLI_CLIENT_INTERACTIVE" => true, "MYSQLI_CLIENT_IGNORE_SPACE" => true, "MYSQLI_CLIENT_NO_SCHEMA" => true, "MYSQLI_CLIENT_FOUND_ROWS" => true, "MYSQLI_STORE_RESULT" => true, "MYSQLI_USE_RESULT" => true, "MYSQLI_ASSOC" => true, "MYSQLI_NUM" => true, "MYSQLI_BOTH" => true, "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH" => true, "MYSQLI_NOT_NULL_FLAG" => true, "MYSQLI_PRI_KEY_FLAG" => true, "MYSQLI_UNIQUE_KEY_FLAG" => true, "MYSQLI_MULTIPLE_KEY_FLAG" => true, "MYSQLI_BLOB_FLAG" => true, "MYSQLI_UNSIGNED_FLAG" => true, "MYSQLI_ZEROFILL_FLAG" => true, "MYSQLI_AUTO_INCREMENT_FLAG" => true, "MYSQLI_TIMESTAMP_FLAG" => true, "MYSQLI_SET_FLAG" => true, "MYSQLI_NUM_FLAG" => true, "MYSQLI_PART_KEY_FLAG" => true, "MYSQLI_GROUP_FLAG" => true, "MYSQLI_TYPE_DECIMAL" => true, "MYSQLI_TYPE_TINY" => true, "MYSQLI_TYPE_SHORT" => true, "MYSQLI_TYPE_LONG" => true, "MYSQLI_TYPE_FLOAT" => true, "MYSQLI_TYPE_DOUBLE" => true, "MYSQLI_TYPE_NULL" => true, "MYSQLI_TYPE_TIMESTAMP" => true, "MYSQLI_TYPE_LONGLONG" => true, "MYSQLI_TYPE_INT24" => true, "MYSQLI_TYPE_DATE" => true, "MYSQLI_TYPE_TIME" => true, "MYSQLI_TYPE_DATETIME" => true, "MYSQLI_TYPE_YEAR" => true, "MYSQLI_TYPE_NEWDATE" => true, "MYSQLI_TYPE_ENUM" => true, "MYSQLI_TYPE_SET" => true, "MYSQLI_TYPE_TINY_BLOB" => true, "MYSQLI_TYPE_MEDIUM_BLOB" => true, "MYSQLI_TYPE_LONG_BLOB" => true, "MYSQLI_TYPE_BLOB" => true, "MYSQLI_TYPE_VAR_STRING" => true, "MYSQLI_TYPE_STRING" => true, "MYSQLI_TYPE_CHAR" => true, "MYSQLI_TYPE_INTERVAL" => true, "MYSQLI_TYPE_GEOMETRY" => true, "MYSQLI_NO_DATA" => true, "MYSQLI_REPORT_INDEX" => true, "MYSQLI_REPORT_STRICT" => true, "MYSQLI_REPORT_ALL" => true, "MYSQLI_REPORT_ERROR" => true, "MYSQLI_REPORT_OFF" => true, "MYSQLI_SET_CHARSET_NAME" => true, ); /* depends on the build - experimental */ if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_YEARS_AS_INT')) $expected_constants['MYSQLI_OPT_INT_AND_YEARS_AS_INT'] = true; if ($IS_MYSQLND) { $version = 50007 + 1; } else { $version = mysqli_get_client_version(); } if ($version > 50002) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_TYPE_NEWDECIMAL" => true, "MYSQLI_TYPE_BIT" => true, )); } if ($version > 50003) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_STMT_ATTR_CURSOR_TYPE" => true, "MYSQLI_CURSOR_TYPE_NO_CURSOR" => true, "MYSQLI_CURSOR_TYPE_READ_ONLY" => true, "MYSQLI_CURSOR_TYPE_FOR_UPDATE" => true, "MYSQLI_CURSOR_TYPE_SCROLLABLE" => true, )); } if ($version > 50007) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true, )); } /* pretty dump test, but that is the best way to mimic mysql.c */ if (defined('MYSQLI_DATA_TRUNCATED')) $expected_constants["MYSQLI_DATA_TRUNCATED"] = true; if ($IS_MYSQLND && $php_version >= 600) { /* mysqlnd only */ $expected_constants["MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE"] = true; } else if (!$IS_MYSQLND) { /* libmysql only */ /* are they available in all versions of ext/mysqli ? */ $expected_constants["MYSQLI_RPL_MASTER"] = true; $expected_constants["MYSQLI_RPL_SLAVE"] = true; $expected_constants["MYSQLI_RPL_ADMIN"] = true; } $unexpected_constants = array(); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysqli')) { $name = strtoupper($name); if (isset($expected_constants[$name])) { unset($expected_constants[$name]); } else { $unexpected_constants[$name] = $name; } } } } if (!empty($unexpected_constants)) { printf("Dumping list of unexpected constants\n"); var_dump($unexpected_constants); } if (!empty($expected_constants)) { printf("Dumping list of missing constants\n"); var_dump($expected_constants); } print "done!"; ?> --EXPECTF-- done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_affected_rows_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_affected_rows_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_affected_rows_oo.phpt --TEST-- mysqli->affected_rows --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } if (0 !== ($tmp = $mysqli->affected_rows)) printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine)) printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('INSERT INTO test(id, label) VALUES (1, "a")')) printf("[005] [%d] %s\n", $mysqli->errno, $mysqli->error); if (1 !== ($tmp = $mysqli->affected_rows)) printf("[006] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); // ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented $mysqli->query('INSERT INTO test(id, label) VALUES (1, "a")'); if (-1 !== ($tmp = $mysqli->affected_rows)) printf("[007] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); if (2 !== ($tmp = $mysqli->affected_rows)) printf("[009] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')")) printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); if (2 !== ($tmp = $mysqli->affected_rows)) printf("[011] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("INSERT IGNORE INTO test(id, label) VALUES (1, 'a')")) { printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); } if (1 !== ($tmp = $mysqli->affected_rows)) printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("INSERT INTO test(id, label) SELECT id + 10, label FROM test")) printf("[014] [%d] %s\n", $mysqli->errno, $mysqli->error); if (4 !== ($tmp = $mysqli->affected_rows)) printf("[015] Expecting int/4, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("REPLACE INTO test(id, label) values (4, 'd')")) printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); if (2 !== ($tmp = $mysqli->affected_rows)) printf("[016] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("REPLACE INTO test(id, label) values (5, 'e')")) printf("[017] [%d] %s\n", $mysqli->errno, $mysqli->error); if (1 !== ($tmp = $mysqli->affected_rows)) printf("[018] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 2")) printf("[019] [%d] %s\n", $mysqli->errno, $mysqli->error); if (1 !== ($tmp = $mysqli->affected_rows)) printf("[020] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 2")) { printf("[021] [%d] %s\n", $mysqli->errno, $mysqli->error); } if (0 !== ($tmp = $mysqli->affected_rows)) printf("[022] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 100")) { printf("[023] [%d] %s\n", $mysqli->errno, $mysqli->error); } if (0 !== ($tmp = $mysqli->affected_rows)) printf("[024] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->affected_rows)) printf("[026] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_affected_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_affected_rows.phpt +++ php-src/ext/mysqli/tests/mysqli_affected_rows.phpt --TEST-- mysqli_affected_rows() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_affected_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_affected_rows($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_affected_rows($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (0 !== ($tmp = mysqli_affected_rows($link))) printf("[005] Expecting int/0, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine)) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'INSERT INTO test(id, label) VALUES (1, "a")')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (1 !== ($tmp = mysqli_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 mysqli_query($link, 'INSERT INTO test(id, label) VALUES (1, "a")'); if (-1 !== ($tmp = mysqli_affected_rows($link))) printf("[011] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4')) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (2 !== ($tmp = mysqli_affected_rows($link))) printf("[013] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')")) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (2 !== ($tmp = mysqli_affected_rows($link))) printf("[015] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT IGNORE INTO test(id, label) VALUES (1, 'a')")) { printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (1 !== ($tmp = mysqli_affected_rows($link))) printf("[017] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT INTO test(id, label) SELECT id + 10, label FROM test")) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (4 !== ($tmp = mysqli_affected_rows($link))) printf("[019] Expecting int/4, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "REPLACE INTO test(id, label) values (4, 'd')")) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (2 !== ($tmp = mysqli_affected_rows($link))) printf("[021] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "REPLACE INTO test(id, label) values (5, 'e')")) printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (1 !== ($tmp = mysqli_affected_rows($link))) printf("[023] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 2")) printf("[024] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (1 !== ($tmp = mysqli_affected_rows($link))) printf("[025] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); $charsets = array('utf8'); foreach ($charsets as $k => $charset) { if (!($res = mysqli_query($link, sprintf('SHOW CHARACTER SET LIKE "%s"', $charset)))) continue; mysqli_free_result($res); if (true !== ($tmp = mysqli_set_charset($link, $charset))) printf("[026] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (0 !== ($tmp = mysqli_affected_rows($link))) printf("[027] Expecting int/0 got %s/%s\n", gettype($tmp), $tmp); } if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 2")) { printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_affected_rows($link))) printf("[029] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 100")) { printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_affected_rows($link))) printf("[031] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = @mysqli_affected_rows($link))) printf("[033] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_autocommit_oo.phpt --TEST-- mysqli->autocommit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { printf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); exit(1); } if (!$res = $mysqli->query("SHOW VARIABLES LIKE 'have_innodb'")) { printf("skip Cannot fetch have_innodb variable\n"); exit(1); } $row = $res->fetch_row(); $res->free_result(); $mysqli->close(); if ($row[1] == "DISABLED" || $row[1] == "NO") { printf ("skip Innodb support is not installed or enabled."); exit(1); } ?> --FILE-- <?php include "connect.inc"; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } if (!is_bool($tmp = $mysqli->autocommit(true))) printf("[002] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('SET AUTOCOMMIT = 0')) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if ($tmp['auto_commit']) printf("[005] Cannot turn off autocommit\n"); if (true !== ($tmp = $mysqli->autocommit( true))) printf("[006] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) printf("[007] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (!$tmp['auto_commit']) printf("[008] Cannot turn on autocommit\n"); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { printf("[010] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); } if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('ROLLBACK')) printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); if ((!$tmp = $res->fetch_assoc()) || (1 != $tmp['num'])) printf("[014] Expecting 1 row in table test, found %d rows. [%d] %s\n", $tmp['num'], $mysqli->errno, $mysqli->error); $res->free_result(); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('SET AUTOCOMMIT = 1')) printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) printf("[017] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (!$tmp['auto_commit']) printf("[018] Cannot turn on autocommit\n"); if (true !== ($tmp = $mysqli->autocommit( false))) printf("[019] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { printf("[020] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); } if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[021] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('ROLLBACK')) printf("[022] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[023] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); if (0 != $tmp['num']) printf("[24] Expecting 0 rows in table test, found %d rows\n", $tmp['num']); $res->free_result(); if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('COMMIT')) printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[027] [%d] %s\n", $mysqli->errno, $mysqli->error); if ((!$tmp = $res->fetch_assoc()) || (1 != $tmp['num'])) printf("[028] Expecting 1 row in table test, found %d rows. [%d] %s\n", $tmp['num'], $mysqli->errno, $mysqli->error); $res->free_result(); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[029] [%d] %s\n", $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->autocommit( false))) printf("[030] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_autocommit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_autocommit.phpt +++ php-src/ext/mysqli/tests/mysqli_autocommit.phpt --TEST-- mysqli_autocommit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); exit(1); } if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) { printf("skip Cannot fetch have_innodb variable\n"); exit(1); } $row = mysqli_fetch_row($res); mysqli_free_result($res); mysqli_close($link); if ($row[1] == "DISABLED" || $row[1] == "NO") { printf ("skip Innodb support is not installed or enabled."); exit(1); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_autocommit())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_autocommit($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_autocommit($link, $link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } if (!is_bool($tmp = mysqli_autocommit($link, true))) printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'SET AUTOCOMMIT = 0')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT @@autocommit as auto_commit')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if ($tmp['auto_commit']) printf("[008] Cannot turn off autocommit\n"); if (true !== ($tmp = mysqli_autocommit($link, true))) printf("[009] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT @@autocommit as auto_commit')) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$tmp['auto_commit']) printf("[011] Cannot turn on autocommit\n"); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) { printf("[013] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'ROLLBACK')) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ((!$tmp = mysqli_fetch_assoc($res)) || (1 != $tmp['num'])) printf("[17] Expecting 1 row in table test, found %d rows. [%d] %s\n", $tmp['num'], mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'SET AUTOCOMMIT = 1')) printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT @@autocommit as auto_commit')) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$tmp['auto_commit']) printf("[021] Cannot turn on autocommit\n"); if (true !== ($tmp = mysqli_autocommit($link, false))) printf("[022] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) { printf("[023] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[024] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'ROLLBACK')) printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (0 != $tmp['num']) printf("[27] Expecting 0 rows in table test, found %d rows\n", $tmp['num']); mysqli_free_result($res); if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'COMMIT')) printf("[029] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if ((!$tmp = mysqli_fetch_assoc($res)) || (1 != $tmp['num'])) printf("[31] Expecting 1 row in table test, found %d rows. [%d] %s\n", $tmp['num'], mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = @mysqli_autocommit($link, false))) printf("[033] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_get_lock.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_get_lock.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_get_lock.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_insert_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_insert_id.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_insert_id.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_oo.phpt --TEST-- mysqli->change_user() --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('table.inc'); if (!$IS_MYSQLND && (mysqli_get_server_version($link) < 50118 && mysqli_get_server_version($link) > 50100)) { die("skip Your MySQL Server version has a known but that will cause a crash"); } ?> --FILE-- <?php include_once("connect.inc"); $link = NULL; $tmp = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->change_user())) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->change_user($link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user . '_unknown_really', $passwd . 'non_empty', $db))) printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user, $passwd . '_unknown_really', $db))) printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $mysqli->change_user($user, $passwd, $db . '_unknown_really'))) printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('SET @mysqli_change_user_test_var=1')) printf("[009] Failed to set test variable: [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (1 != $tmp['test_var']) printf("[011] Cannot set test variable\n"); if (true !== ($tmp = $mysqli->change_user($user, $passwd, $db))) printf("[012] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT database() AS dbname, user() AS user')) printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (substr($tmp['user'], 0, strlen($user)) !== $user) printf("[014] Expecting user %s, got user() %s\n", $user, $tmp['user']); if ($tmp['dbname'] != $db) printf("[015] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (NULL !== $tmp['test_var']) printf("[017] Test variable is still set!\n"); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->change_user($user, $passwd, $db))) printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user.phpt --TEST-- mysqli_change_user() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_change_user())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link, $link))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_change_user($link, $link, $link, $link, $link))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (false !== ($tmp = mysqli_change_user($link, $user . '_unknown_really', $passwd . 'non_empty', $db))) printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_change_user($link, $user, $passwd . '_unknown_really', $db))) printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = mysqli_change_user($link, $user, $passwd, $db . '_unknown_really'))) printf("[009] Expecting false, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'SET @mysqli_change_user_test_var=1')) printf("[010] Failed to set test variable: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (1 != $tmp['test_var']) printf("[012] Cannot set test variable\n"); if (true !== ($tmp = mysqli_change_user($link, $user, $passwd, $db))) printf("[013] Expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, 'SELECT database() AS dbname, user() AS user')) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (substr($tmp['user'], 0, strlen($user)) !== $user) printf("[015] Expecting user %s, got user() %s\n", $user, $tmp['user']); if ($tmp['dbname'] != $db) printf("[016] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (NULL !== $tmp['test_var']) printf("[019] Test variable is still set!\n"); mysqli_close($link); if (NULL !== ($tmp = @mysqli_change_user($link, $user, $passwd, $db))) printf("[020] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_rollback.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_rollback.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_rollback.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_change_user_set_names.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_change_user_set_names.phpt +++ php-src/ext/mysqli/tests/mysqli_change_user_set_names.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set_name_oo.phpt --TEST-- mysqli_chararcter_set_name(), mysql_client_encoding() [alias] --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->character_set_name($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$res = $mysqli->query('SELECT version() AS server_version')) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[007] Need MySQL Server 4.1+ for the test!\n"); if (!$res = $mysqli->query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if (!$tmp['charset']) printf("[009] Cannot determine current character set and collation\n"); $charset = $mysqli->character_set_name(); if ($tmp['charset'] !== $charset) { if ($tmp['collation'] === $charset) { printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", $tmp['collation'], $tmp['charset'], gettype($charset), $charset); } else { printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); } } $charset2 = $mysqli->character_set_name(); if ($charset2 !== $charset) { printf("[012] Alias mysqli_client_encoding returned %s/%s, expected %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset); } $mysqli->close(); if (NULL !== ($tmp = @$mysqli->character_set_name())) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (!is_null($tmp = @$mysqli->client_encoding())) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set_name.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set_name.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set_name.phpt --TEST-- mysqli_chararcter_set_name(), mysql_client_encoding() [alias] --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php /* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */ include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_character_set_name())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_character_set_name($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_character_set_name($link, $link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[007] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!$tmp['charset']) printf("[009] Cannot determine current character set and collation\n"); $charset = mysqli_character_set_name($link); if ($tmp['charset'] !== $charset) { if ($tmp['collation'] === $charset) { printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", $tmp['collation'], $tmp['charset'], gettype($charset), $charset); } else { printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); } } $charset2 = mysqli_client_encoding($link); if ($charset2 !== $charset) { printf("[012] Alias mysqli_client_encoding returned %s/%s, expected %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset); } mysqli_close($link); if (NULL !== ($tmp = @mysqli_character_set_name($link))) printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); /* Make sure that the function alias exists */ if (!is_null($tmp = @mysqli_client_encoding())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_character_set.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_character_set.phpt +++ php-src/ext/mysqli/tests/mysqli_character_set.phpt --TEST-- Fetching results from tables of different charsets. --SKIPIF-- <?php require_once('skipifunicode.inc'); ?> <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (ini_get("unicode.semantics")){ die('done!'); } if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); $version = explode('.', $tmp['server_version']); if (empty($version)) printf("[003] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[004] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, "SHOW CHARACTER SET")) printf("[005] Cannot get list of available character sets, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $charsets = array(); while ($row = mysqli_fetch_assoc($res)) $charsets[] = $row; mysqli_free_result($res); foreach ($charsets as $k => $charset) { /* The server currently 17.07.2007 can't handle data sent in ucs2 */ if ($charset['Charset'] == 'ucs2') { continue; } if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[006 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); $sql = sprintf("CREATE TABLE test(id INT, label CHAR(1)) CHARACTER SET '%s' ", $charset['Charset']); if (!mysqli_query($link, $sql)) { printf("[007 + %d] %s [%d] %s\n", $k, $sql, mysqli_errno($link), mysqli_error($link)); continue; } if (!mysqli_set_charset($link, $charset['Charset'])) { printf("[008 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); continue; } for ($i = 1; $i <= 3; $i++) { if (!mysqli_query($link, sprintf("INSERT INTO test (id, label) VALUES (%d, '%s')", $i, mysqli_real_escape_string($link, chr(ord("a") + $i))))) { var_dump($charset['Charset']); printf("[009 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); continue; } } if (!$res = mysqli_query($link, "SELECT id, label FROM test")) printf("[010 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); for ($i = 1; $i <= 3; $i++) { if (!$tmp = mysqli_fetch_assoc($res)) printf("[011 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link)); if ($tmp['id'] != $i) printf("[012 + %d] Expecting %d, got %s, [%d] %s\n", $k, $i, $tmp['id'], mysqli_errno($link), mysqli_error($link)); if ($tmp['label'] != chr(ord("a") + $i)) printf("[013 + %d] Expecting %d, got %s, [%d] %s\n", $k, chr(ord("a") + $i), $tmp['label'], mysqli_errno($link), mysqli_error($link)); } mysqli_free_result($res); } mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt --TEST-- Interface of the class mysqli_driver --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); require('table.inc'); $driver = new mysqli_driver(); printf("Parent class:\n"); var_dump(get_parent_class($driver)); printf("\nMethods:\n"); $methods = get_class_methods($driver); $expected_methods = array(); if (!$IS_MYSQLND) { /* libmysql only */ $expected_methods = array_merge($expected_methods, array( 'embedded_server_start' => true, 'embedded_server_end' => true, )); } foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($expected_methods[$method]); unset($methods[$k]); } } if (!empty($expected_methods)) { printf("Dumping list of missing methods.\n"); var_dump($expected_methods); } if (!empty($methods)) { printf("Dumping list of unexpected methods.\n"); var_dump($methods); } if (empty($expected_methods) && empty($methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($driver)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($driver); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert(mysqli_get_client_info() === $driver->client_info); printf("driver->client_info = '%s'\n", $driver->client_info); assert(mysqli_get_client_version() === $driver->client_version); printf("driver->client_version = '%s'\n", $driver->client_version); assert($driver->driver_version > 0); printf("driver->driver_version = '%s'\n", $driver->driver_version); assert(in_array($driver->report_mode, array( MYSQLI_REPORT_ALL, MYSQLI_REPORT_STRICT, MYSQLI_REPORT_ERROR, MYSQLI_REPORT_INDEX, MYSQLI_REPORT_OFF ) )); printf("driver->report_mode = '%s'\n", $driver->report_mode); $driver->report_mode = MYSQLI_REPORT_STRICT; assert($driver->report_mode === MYSQLI_REPORT_STRICT); assert(is_bool($driver->embedded)); printf("driver->embedded = '%s'\n", $driver->embedded); printf("driver->reconnect = '%s'\n", $driver->reconnect); printf("\nAccess to undefined properties:\n"); printf("driver->unknown = '%s'\n", @$driver->unknown); print "done!"; ?> --EXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: driver->client_info = '%s' driver->client_version = '%d' driver->driver_version = '%d' driver->report_mode = '%d' driver->embedded = '' driver->reconnect = '' Access to undefined properties: driver->unknown = '' done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt --TEST-- Interface of the class mysqli_driver - Reflection --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (($tmp = substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.'))) && ($tmp < 5)) die("skip Reflection not available before PHP 5 (found PHP $tmp)"); /* Let's not deal with cross-version issues in the EXPECTF/UEXPECTF. Most of the things which we test are covered by mysqli_class_*_interface.phpt. Those tests go into the details and are aimed to be a development tool, no more. */ if (!$IS_MYSQLND) die("skip Test has been written for the latest version of mysqlnd only"); if ($MYSQLND_VERSION < 576) die("skip Test requires mysqlnd Revision 576 or newer"); ?> --FILE-- <?php require_once('reflection_tools.inc'); $class = new ReflectionClass('mysqli_driver'); inspectClass($class); print "done!"; ?> --EXPECTF-- Inspecting class 'mysqli_driver' isInternal: yes isUserDefined: no isInstantiable: yes isInterface: no isAbstract: no isFinal: yes isIteratable: no Modifiers: '%d' Parent Class: '' Extension: 'mysqli' done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt --TEST-- Interface of the class mysqli --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); printf("Parent class:\n"); var_dump(get_parent_class($mysqli)); printf("\nMethods:\n"); $methods = get_class_methods($mysqli); $expected_methods = array( 'autocommit' => true, 'change_user' => true, 'character_set_name' => true, 'client_encoding' => true, 'close' => true, 'commit' => true, 'connect' => true, 'dump_debug_info' => true, 'escape_string' => true, 'get_charset' => true, 'get_client_info' => true, 'get_server_info' => true, 'get_warnings' => true, 'init' => true, 'kill' => true, 'more_results' => true, 'multi_query' => true, 'mysqli' => true, 'next_result' => true, 'options' => true, 'ping' => true, 'prepare' => true, 'query' => true, 'real_connect' => true, 'real_escape_string' => true, 'real_query' => true, 'rollback' => true, 'select_db' => true, 'set_charset' => true, 'set_local_infile_default' => true, 'set_local_infile_handler' => true, 'set_opt' => true, 'stat' => true, 'stmt_init' => true, 'store_result' => true, 'thread_safe' => true, 'use_result' => true, ); if ($IS_MYSQLND) { // mysqlnd only /* $expected_methods['get_cache_stats'] = true; */ /* $expected_methods['get_client_stats'] = true; */ $expected_methods['get_connection_stats'] = true; } else { // libmysql only if (function_exists('mysqli_disable_reads_from_master')) $expected_methods['disable_reads_from_master'] = true; if (function_exists('mysqli_disable_rpl_parse')) $expected_methods['disable_rpl_parse'] = true; if (function_exists('mysqli_enable_reads_from_master')) $expected_methods['enable_reads_from_master'] = true; if (function_exists('mysqli_enable_rpl_parse')) $expected_methods['enable_rpl_parse'] = true; if (function_exists('mysqli_master_query')) $expected_methods['master_query'] = true; if (function_exists('mysqli_rpl_parse_enabled')) $expected_methods['rpl_parse_enabled'] = true; if (function_exists('mysqli_rpl_probe')) $expected_methods['rpl_probe'] = true; if (function_exists('mysqli_rpl_query_type')) $expected_methods['rpl_query_type'] = true; if (function_exists('mysqli_slave_query')) $expected_methods['slave_query'] = true; if (function_exists('mysqli_ssl_set')) $expected_methods['ssl_set'] = true; } /* we should add ruled when to expect them */ if (function_exists('mysqli_debug')) $expected_methods['debug'] = true; if (function_exists('ssl_set')) $expected_methods['ssl_set'] = true; foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($methods[$k]); unset($expected_methods[$method]); } } if (!empty($methods)) { printf("Dumping list of unexpected methods.\n"); var_dump($methods); } if (!empty($expected_methods)) { printf("Dumping list of missing methods.\n"); var_dump($expected_methods); } if (empty($methods) && empty($expected_methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($mysqli)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($mysqli); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert(mysqli_affected_rows($link) === $mysqli->affected_rows); printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n", $mysqli->affected_rows, gettype($mysqli->affected_rows), mysqli_affected_rows($link), gettype(mysqli_affected_rows($link))); assert(mysqli_get_client_info() === $mysqli->client_info); printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n", $mysqli->client_info, gettype($mysqli->client_info), mysqli_get_client_info(), gettype(mysqli_get_client_info())); assert(mysqli_get_client_version() === $mysqli->client_version); printf("mysqli->client_version = '%s'/%s ('%s'/%s)\n", $mysqli->client_version, gettype($mysqli->client_version), mysqli_get_client_version(), gettype(mysqli_get_client_version())); assert(mysqli_errno($link) === $mysqli->errno); printf("mysqli->errno = '%s'/%s ('%s'/%s)\n", $mysqli->errno, gettype($mysqli->errno), mysqli_errno($link), gettype(mysqli_errno($link))); assert(mysqli_error($link) === $mysqli->error); printf("mysqli->error = '%s'/%s ('%s'/%s)\n", $mysqli->error, gettype($mysqli->error), mysqli_error($link), gettype(mysqli_error($link))); assert(mysqli_field_count($link) === $mysqli->field_count); printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n", $mysqli->field_count, gettype($mysqli->field_count), mysqli_field_count($link), gettype(mysqli_field_count($link))); assert(mysqli_insert_id($link) === $mysqli->insert_id); printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n", $mysqli->insert_id, gettype($mysqli->insert_id), mysqli_insert_id($link), gettype(mysqli_insert_id($link))); assert(mysqli_sqlstate($link) === $mysqli->sqlstate); printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n", $mysqli->sqlstate, gettype($mysqli->sqlstate), mysqli_sqlstate($link), gettype(mysqli_sqlstate($link))); assert(mysqli_get_host_info($link) === $mysqli->host_info); printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n", $mysqli->host_info, gettype($mysqli->host_info), mysqli_get_host_info($link), gettype(mysqli_get_host_info($link))); /* note that the data types are different */ assert(mysqli_info($link) == $mysqli->info); printf("mysqli->info = '%s'/%s ('%s'/%s)\n", $mysqli->info, gettype($mysqli->info), mysqli_info($link), gettype(mysqli_info($link))); assert(mysqli_thread_id($link) > $mysqli->thread_id); assert(gettype($mysqli->thread_id) == gettype(mysqli_thread_id($link))); printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n", $mysqli->thread_id, gettype($mysqli->thread_id), mysqli_thread_id($link), gettype(mysqli_thread_id($link))); assert(mysqli_get_proto_info($link) === $mysqli->protocol_version); printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n", $mysqli->protocol_version, gettype($mysqli->protocol_version), mysqli_get_proto_info($link), gettype(mysqli_get_proto_info($link))); assert(mysqli_get_server_info($link) === $mysqli->server_info); printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n", $mysqli->server_info, gettype($mysqli->server_info), mysqli_get_server_info($link), gettype(mysqli_get_server_info($link))); assert(mysqli_get_server_version($link) === $mysqli->server_version); printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n", $mysqli->server_version, gettype($mysqli->server_version), mysqli_get_server_version($link), gettype(mysqli_get_server_version($link))); assert(mysqli_warning_count($link) === $mysqli->warning_count); printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n", $mysqli->warning_count, gettype($mysqli->warning_count), mysqli_warning_count($link), gettype(mysqli_warning_count($link))); printf("\nAccess to undefined properties:\n"); printf("mysqli->unknown = '%s'\n", @$mysqli->unknown); @$mysqli->unknown = 13; printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); $unknown = 'friday'; @$mysqli->unknown = $unknown; printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n"); assert(mysqli_connect_error() === $mysqli->connect_error); printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", $mysqli->connect_error, gettype($mysqli->connect_error), mysqli_connect_error(), gettype(mysqli_connect_error())); assert(mysqli_connect_errno() === $mysqli->connect_errno); printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", $mysqli->connect_errno, gettype($mysqli->connect_errno), mysqli_connect_errno(), gettype(mysqli_connect_errno())); print "done!"; ?> --EXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: mysqli->affected_rows = '%s'/integer ('%s'/integer) mysqli->client_info = '%s'/string ('%s'/string) mysqli->client_version = '%d'/integer ('%d'/integer) mysqli->errno = '0'/integer ('0'/integer) mysqli->error = ''/string (''/string) mysqli->field_count = '0'/integer ('0'/integer) mysqli->insert_id = '0'/integer ('0'/integer) mysqli->sqlstate = '00000'/string ('00000'/string) mysqli->host_info = '%s'/string ('%s'/string) mysqli->info = ''/NULL (''/string) mysqli->thread_id = '%d'/integer ('%d'/integer) mysqli->protocol_version = '%d'/integer ('%d'/integer) mysqli->server_info = '%s'/string ('%s'/string) mysqli->server_version = '%d'/integer ('%d'/integer) mysqli->warning_count = '0'/integer ('0'/integer) Access to undefined properties: mysqli->unknown = '' setting mysqli->unknown, mysqli_unknown = '13' setting mysqli->unknown, mysqli_unknown = 'friday' Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation): mysqli->connect_error = ''/string (''/string) mysqli->connect_errno = '0'/integer ('0'/integer) done! --UEXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: mysqli->affected_rows = '%s'/integer ('%s'/integer) mysqli->client_info = '%s'/unicode ('%s'/unicode) mysqli->client_version = '%d'/integer ('%d'/integer) mysqli->errno = '0'/integer ('0'/integer) mysqli->error = ''/unicode (''/unicode) mysqli->field_count = '0'/integer ('0'/integer) mysqli->insert_id = '0'/integer ('0'/integer) mysqli->sqlstate = '00000'/unicode ('00000'/unicode) mysqli->host_info = '%s'/unicode ('%s'/unicode) mysqli->info = ''/NULL (''/unicode) mysqli->thread_id = '%d'/integer ('%d'/integer) mysqli->protocol_version = '%d'/integer ('%d'/integer) mysqli->server_info = '%s'/unicode ('%s'/unicode) mysqli->server_version = '%d'/integer ('%d'/integer) mysqli->warning_count = '0'/integer ('0'/integer) Access to undefined properties: mysqli->unknown = '' setting mysqli->unknown, mysqli_unknown = '13' setting mysqli->unknown, mysqli_unknown = 'friday' Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation): mysqli->connect_error = ''/unicode (''/unicode) mysqli->connect_errno = '0'/integer ('0'/integer) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt --TEST-- Interface of the class mysqli - Reflection --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (($tmp = substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.'))) && ($tmp < 5)) die("skip Reflection not available before PHP 5 (found PHP $tmp)"); /* Let's not deal with cross-version issues in the EXPECTF/UEXPECTF. Most of the things which we test are covered by mysqli_class_*_interface.phpt. Those tests go into the details and are aimed to be a development tool, no more. */ if (!$IS_MYSQLND) die("skip Test has been written for the latest version of mysqlnd only"); if ($MYSQLND_VERSION < 576) die("skip Test requires mysqlnd Revision 576 or newer"); ?> --FILE-- <?php require_once('reflection_tools.inc'); $class = new ReflectionClass('mysqli'); inspectClass($class); print "done!"; ?> --EXPECTF-- Inspecting class 'mysqli' isInternal: yes isUserDefined: no isInstantiable: yes isInterface: no isAbstract: no isFinal: no isIteratable: no Modifiers: '0' Parent Class: '' Extension: 'mysqli' Inspecting method 'mysqli' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 8448 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'autocommit' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'change_user' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'character_set_name' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'client_encoding' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'close' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'commit' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'connect' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'debug' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'dump_debug_info' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'escape_string' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_charset' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_client_info' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_connection_stats' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_server_info' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'get_warnings' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'init' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'kill' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'more_results' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'multi_query' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'mysqli' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 8448 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'next_result' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'options' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'ping' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'prepare' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'query' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'real_connect' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'real_escape_string' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'real_query' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'rollback' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'select_db' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'set_charset' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'set_local_infile_default' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'set_local_infile_handler' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'set_opt' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'stat' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'stmt_init' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'store_result' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'thread_safe' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'use_result' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt --TEST-- Interface of the class mysqli_result --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); require('table.inc'); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); $mysqli_result = $mysqli->query('SELECT * FROM test'); $row = $mysqli_result->fetch_row(); $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); $res = mysqli_query($link, 'SELECT * FROM test'); assert(mysqli_fetch_row($res) === $row); printf("Parent class:\n"); var_dump(get_parent_class($mysqli_result)); printf("\nMethods:\n"); $methods = get_class_methods($mysqli_result); $expected_methods = array( '__construct' => true, 'close' => true, 'data_seek' => true, 'fetch_array' => true, 'fetch_assoc' => true, 'fetch_field' => true, 'fetch_field_direct' => true, 'fetch_fields' => true, 'fetch_object' => true, 'fetch_row' => true, 'field_seek' => true, 'free' => true, 'free_result' => true, ); if ($IS_MYSQLND) $expected_methods['fetch_all'] = true; foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($expected_methods[$method]); unset($methods[$k]); } if ($method == 'mysqli_result') { // get_class_method reports different constructor names unset($expected_methods['__construct']); unset($methods[$k]); } } if (!empty($expected_methods)) { printf("Dumping list of missing methods.\n"); var_dump($expected_methods); } if (!empty($methods)) { printf("Dumping list of unexpected methods.\n"); var_dump($methods); } if (empty($expected_methods) && empty($methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($mysqli_result)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($mysqli_result); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert(($tmp = mysqli_field_tell($res)) === $mysqli_result->current_field); printf("mysqli_result->current_field = '%s'/%s ('%s'/%s)\n", $mysqli_result->current_field, gettype($mysqli_result->current_field), $tmp, gettype($tmp)); assert(($tmp = mysqli_field_count($link)) === $mysqli_result->field_count); printf("mysqli_result->field_count = '%s'/%s ('%s'/%s)\n", $mysqli_result->field_count, gettype($mysqli_result->field_count), $tmp, gettype($tmp)); assert(($tmp = mysqli_fetch_lengths($res)) === $mysqli_result->lengths); printf("mysqli_result->lengths -> '%s'/%s ('%s'/%s)\n", ((is_array($mysqli_result->lengths)) ? implode(' ', $mysqli_result->lengths) : 'n/a'), gettype($mysqli_result->lengths), ((is_array($tmp)) ? implode(' ', $tmp) : 'n/a'), gettype($tmp)); assert(($tmp = mysqli_num_rows($res)) === $mysqli_result->num_rows); printf("mysqli_result->num_rows = '%s'/%s ('%s'/%s)\n", $mysqli_result->num_rows, gettype($mysqli_result->num_rows), $tmp, gettype($tmp)); assert(in_array($mysqli_result->type, array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT))); printf("mysqli_result->type = '%s'/%s\n", ((MYSQLI_STORE_RESULT == $mysqli_result->type) ? 'store' : 'use'), gettype($mysqli_result->type)); printf("\nAccess to undefined properties:\n"); printf("mysqli_result->unknown = '%s'\n", @$mysqli_result->unknown); printf("\nConstructor:\n"); if (!is_object($res = new mysqli_result($link))) printf("[001] Expecting object/mysqli_result got %s/%s\n", gettye($res), $res); if (null !== ($tmp = @$res->num_rows)) printf("[002] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "SELECT id FROM test ORDER BY id")) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = new mysqli_result($link))) printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = new mysqli_result($link, MYSQLI_STORE_RESULT))) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = new mysqli_result($link, MYSQLI_USE_RESULT))) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = new mysqli_result($link, 'invalid'))) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT); do { $mode = mt_rand(-1000, 1000); } while (in_array($mode, $valid)); if ($TEST_EXPERIMENTAL) { ob_start(); if (!is_object($res = new mysqli_result($link, $mode))) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $content = ob_get_contents(); ob_end_clean(); if (!stristr($content, 'Invalid value for resultmode')) printf("[009] Expecting warning because of invalid resultmode\n"); } if (!is_object($res = new mysqli_result('foo'))) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = @new mysqli_result($link, MYSQLI_STORE_RESULT, 1))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); print "done!"; ?> --EXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: mysqli_result->current_field = '0'/integer ('0'/integer) mysqli_result->field_count = '2'/integer ('2'/integer) mysqli_result->lengths -> '1 1'/array ('1 1'/array) mysqli_result->num_rows = '6'/integer ('6'/integer) mysqli_result->type = 'store'/integer Access to undefined properties: mysqli_result->unknown = '' Constructor: Warning: mysqli_result::mysqli_result() expects parameter 2 to be long, string given in %s on line %d Warning: mysqli_result::mysqli_result() expects parameter 1 to be mysqli, string given in %s on line %d done! --UEXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: mysqli_result->current_field = '0'/integer ('0'/integer) mysqli_result->field_count = '2'/integer ('2'/integer) mysqli_result->lengths -> '1 1'/array ('1 1'/array) mysqli_result->num_rows = '6'/integer ('6'/integer) mysqli_result->type = 'store'/integer Access to undefined properties: mysqli_result->unknown = '' Constructor: Warning: mysqli_result::mysqli_result() expects parameter 2 to be long, Unicode string given in %s on line %d Warning: mysqli_result::mysqli_result() expects parameter 1 to be mysqli, Unicode string given in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt --TEST-- Interface of the class mysqli_result - Reflection --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (($tmp = substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.'))) && ($tmp < 5)) die("skip Reflection not available before PHP 5 (found PHP $tmp)"); /* Let's not deal with cross-version issues in the EXPECTF/UEXPECTF. Most of the things which we test are covered by mysqli_class_*_interface.phpt. Those tests go into the details and are aimed to be a development tool, no more. */ if (!$IS_MYSQLND) die("skip Test has been written for the latest version of mysqlnd only"); if ($MYSQLND_VERSION < 576) die("skip Test requires mysqlnd Revision 576 or newer"); ?> --FILE-- <?php require_once('reflection_tools.inc'); $class = new ReflectionClass('mysqli_result'); inspectClass($class); print "done!"; ?> --EXPECTF-- Inspecting class 'mysqli_result' isInternal: yes isUserDefined: no isInstantiable: yes isInterface: no isAbstract: no isFinal: no isIteratable: no Modifiers: '0' Parent Class: '' Extension: 'mysqli' Inspecting method '__construct' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method '__construct' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'close' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'data_seek' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_all' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_array' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_assoc' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_field' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_field_direct' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_fields' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_object' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'fetch_row' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'field_seek' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'free' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'free_result' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt --TEST-- Interface of the class mysqli_stmt --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require('connect.inc'); require('table.inc'); $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); $stmt = new mysqli_stmt($link); printf("Parent class:\n"); var_dump(get_parent_class($stmt)); printf("\nMethods:\n"); $methods = get_class_methods($stmt); $expected_methods = array( '__construct' => true, 'attr_get' => true, 'attr_set' => true, 'bind_param' => true, 'bind_result' => true, 'close' => true, 'data_seek' => true, 'execute' => true, 'fetch' => true, 'free_result' => true, 'get_warnings' => true, 'num_rows' => true, 'prepare' => true, 'reset' => true, 'result_metadata' => true, 'send_long_data' => true, 'stmt' => true, 'store_result' => true, ); if ($IS_MYSQLND) $expected_methods['get_result'] = true; foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($methods[$k]); unset($expected_methods[$method]); } if ($method == 'mysqli_stmt') { // get_class_method reports different constructor names unset($expected_methods['__construct']); unset($methods[$k]); } } if (!empty($methods)) { printf("More methods found than indicated. Dumping list of unexpected methods.\n"); var_dump($methods); } if (!empty($expected_methods)) { printf("Some methods are missing. Dumping list of missing methods.\n"); var_dump($expected_methods); } if (empty($methods) && empty($expected_methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($stmt)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($stmt); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert(mysqli_stmt_affected_rows($stmt) === $stmt->affected_rows); printf("stmt->affected_rows = '%s'\n", $stmt->affected_rows); if (!$stmt->prepare("INSERT INTO test(id, label) VALUES (100, 'z')") || !$stmt->execute()) printf("[001] [%d] %s\n", $stmt->errno, $stmt->error); assert(mysqli_stmt_affected_rows($stmt) === $stmt->affected_rows); printf("stmt->affected_rows = '%s'\n", $stmt->affected_rows); assert(mysqli_stmt_errno($stmt) === $stmt->errno); printf("stmt->errno = '%s'\n", $stmt->errno); assert(mysqli_stmt_error($stmt) === $stmt->error); printf("stmt->error = '%s'\n", $stmt->error); assert(mysqli_stmt_field_count($stmt) === $stmt->field_count); printf("stmt->field_count = '%s'\n", $stmt->field_count); assert($stmt->id > 0); printf("stmt->id = '%s'\n", $stmt->id); assert(mysqli_stmt_insert_id($stmt) === $stmt->insert_id); printf("stmt->insert_id = '%s'\n", $stmt->insert_id); assert(mysqli_stmt_num_rows($stmt) === $stmt->num_rows); printf("stmt->num_rows = '%s'\n", $stmt->num_rows); assert(mysqli_stmt_param_count($stmt) === $stmt->param_count); printf("stmt->param_count = '%s'\n", $stmt->param_count); assert(mysqli_stmt_sqlstate($stmt) === $stmt->sqlstate); printf("stmt->sqlstate = '%s'\n", $stmt->sqlstate); printf("\nAccess to undefined properties:\n"); printf("stmt->unknown = '%s'\n", @$stmt->unknown); @$stmt->unknown = 13; printf("stmt->unknown = '%s'\n", @$stmt->unknown); printf("\nPrepare using the constructor:\n"); $stmt = new mysqli_stmt($link, 'SELECT id FROM test ORDER BY id'); if (!$stmt->execute()) printf("[002] [%d] %s\n", $stmt->errno, $stmt->error); $stmt->close(); $obj = new stdClass(); if (!is_object($stmt = new mysqli_stmt($link, $obj))) printf("[003] Expecting NULL got %s/%s\n", gettype($stmt), $stmt); print "done!"; ?> --EXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: Warning: mysqli_stmt_affected_rows(): invalid object or resource mysqli_stmt in %s on line %d Warning: main(): Property access is not allowed yet in %s on line %d Warning: main(): Property access is not allowed yet in %s on line %d stmt->affected_rows = '' stmt->affected_rows = '1' stmt->errno = '0' stmt->error = '' stmt->field_count = '0' stmt->id = '%d' stmt->insert_id = '0' stmt->num_rows = '0' stmt->param_count = '0' stmt->sqlstate = '00000' Access to undefined properties: stmt->unknown = '' stmt->unknown = '13' Prepare using the constructor: Warning: mysqli_stmt::mysqli_stmt() expects parameter 2 to be string, object given in %s on line %d done! --UEXPECTF-- Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: Warning: mysqli_stmt_affected_rows(): invalid object or resource mysqli_stmt in %s on line %d Warning: main(): Property access is not allowed yet in %s on line %d Warning: main(): Property access is not allowed yet in %s on line %d stmt->affected_rows = '' stmt->affected_rows = '1' stmt->errno = '0' stmt->error = '' stmt->field_count = '0' stmt->id = '%d' stmt->insert_id = '0' stmt->num_rows = '0' stmt->param_count = '0' stmt->sqlstate = '00000' Access to undefined properties: stmt->unknown = '' stmt->unknown = '13' Prepare using the constructor: Warning: mysqli_stmt::mysqli_stmt() expects parameter 2 to be binary string, object given in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt --TEST-- Interface of the class mysqli_warning - TODO --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php require('connect.inc'); $warning = new mysqli_warning(); $warning = new mysqli_warning(null); $warning = new mysqli_warning(null, null); $mysqli = new mysqli(); $warning = new mysqli_warning($mysqli); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); $stmt = new mysqli_stmt($mysqli); $warning = new mysqli_warning($stmt); $stmt = $mysqli->stmt_init(); $warning = new mysqli_warning($stmt); $obj = new stdClass(); $warning = new mysqli_warning($obj); include("table.inc"); $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); $res = $mysqli->query('INSERT INTO test(id, label) VALUES (1, "zz")'); $warning = mysqli_get_warnings($mysqli); printf("Parent class:\n"); var_dump(get_parent_class($warning)); printf("\nMethods:\n"); $methods = get_class_methods($warning); $expected_methods = array( 'next' => true, ); foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { unset($methods[$k]); unset($expected_methods[$method]); } } if (!empty($methods)) { printf("Dumping list of unexpected methods.\n"); var_dump($methods); } if (!empty($expected_methods)) { printf("Dumping list of missing methods.\n"); var_dump($expected_methods); } if (empty($methods) && empty($expected_methods)) printf("ok\n"); printf("\nClass variables:\n"); $variables = get_class_vars(get_class($mysqli)); sort($variables); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nObject variables:\n"); $variables = get_object_vars($mysqli); foreach ($variables as $k => $var) printf("%s\n", $var); printf("\nMagic, magic properties:\n"); assert('' === $warning->message); printf("warning->message = '%s'\n", $warning->message); assert('' === $warning->sqlstate); printf("warning->sqlstate= '%s'\n", $warning->sqlstate); assert(0 === $warning->errno); printf("warning->errno = '%s'\n", $warning->errno); printf("\nAccess to undefined properties:\n"); printf("warning->unknown = '%s'\n", @$warning->unknown); print "done!"; ?> --EXPECTF-- Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d Warning: mysqli_warning::mysqli_warning() expects parameter 1 to be object, null given in %s on line %d Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d Warning: mysqli_warning::mysqli_warning(): Couldn't fetch mysqli in %s on line %d Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt in %s on line %d Warning: mysqli_warning::mysqli_warning(): invalid class argument in /home/nixnutz/php6_mysqlnd/ext/mysqli/tests/mysqli_class_mysqli_warning.php on line 19 Warning: mysqli_warning::mysqli_warning(): No warnings found in %s on line %d Parent class: bool(false) Methods: ok Class variables: Object variables: Magic, magic properties: warning->message = '' warning->sqlstate= '' warning->errno = '' Access to undefined properties: warning->unknown = '' done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt +++ php-src/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt --TEST-- Interface of the class mysqli_stmt - Reflection --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (($tmp = substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.'))) && ($tmp < 5)) die("skip Reflection not available before PHP 5 (found PHP $tmp)"); /* Let's not deal with cross-version issues in the EXPECTF/UEXPECTF. Most of the things which we test are covered by mysqli_class_*_interface.phpt. Those tests go into the details and are aimed to be a development tool, no more. */ if (!$IS_MYSQLND) die("skip Test has been written for the latest version of mysqlnd only"); if ($MYSQLND_VERSION < 576) die("skip Test requires mysqlnd Revision 576 or newer"); ?> --FILE-- <?php require_once('reflection_tools.inc'); $class = new ReflectionClass('mysqli_warning'); inspectClass($class); print "done!"; ?> --EXPECTF-- Inspecting class 'mysqli_warning' isInternal: yes isUserDefined: no isInstantiable: no isInterface: no isAbstract: no isFinal: yes isIteratable: no Modifiers: '%d' Parent Class: '' Extension: 'mysqli' Inspecting method '__construct' isFinal: no isAbstract: no isPublic: no isPrivate: no isProtected: yes isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method '__construct' isFinal: no isAbstract: no isPublic: no isPrivate: no isProtected: yes isStatic: no isConstructor: yes isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 Inspecting method 'next' isFinal: no isAbstract: no isPublic: yes isPrivate: no isProtected: no isStatic: no isConstructor: no isDestructor: no isInternal: yes isUserDefined: no returnsReference: no Modifiers: %d Number of Parameters: 0 Number of Required Parameters: 0 done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_close_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_close_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_close_oo.phpt --TEST-- mysqli_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->close($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $tmp = $mysqli->close(); if (true !== $tmp) printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->close())) printf("[004] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @$mysqli->query("SELECT 1"))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_close.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_close.phpt +++ php-src/ext/mysqli/tests/mysqli_close.phpt --TEST-- mysqli_close() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_close())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_close($link, $link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); $tmp = @mysqli_close(NULL); if (NULL !== $tmp) printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); $tmp = mysqli_close($link); if (true !== $tmp) printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_query($link, "SELECT 1"))) printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_commit_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_commit_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_commit_oo.phpt --TEST-- mysqli_commit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = $mysqli->query("SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = $res->fetch_row(); $res->free(); $mysqli->close(); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $mysqli = new mysqli(); if (!is_null($tmp = @$mysqli->commit())) printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!is_null($tmp = @$mysqli->commit($link))) printf("[002] Expecting NULL/NULL, got %s/%s, [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); if (true !== ($tmp = $mysqli->commit())) printf("[014] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $mysqli->autocommit(false))) printf("[003] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[005] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) printf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $mysqli->commit(); if ($tmp !== true) printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('ROLLBACK')) printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); if (1 != $tmp['num']) printf("[010] Expecting 1 row in table test, found %d rows\n", $tmp['num']); $res->free(); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); $mysqli->close(); if (NULL !== ($tmp = @$mysqli->commit())) printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_commit.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_commit.phpt +++ php-src/ext/mysqli/tests/mysqli_commit.phpt --TEST-- mysqli_commit() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?PHP if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket)); } if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) { die(sprintf("skip Cannot fetch have_innodb variable\n")); } $row = mysqli_fetch_row($res); mysqli_free_result($res); mysqli_close($link); if ($row[1] == "DISABLED" || $row[1] == "NO") { die(sprintf ("skip Innodb support is not installed or enabled.")); } ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_commit())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_commit($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_commit($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (true !== ($tmp = mysqli_autocommit($link, false))) printf("[005] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) printf("[007] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_commit($link); if ($tmp !== true) printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, 'ROLLBACK')) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test')) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (1 != $tmp['num']) printf("[12] Expecting 1 row in table test, found %d rows\n", $tmp['num']); mysqli_free_result($res); if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); if (NULL !== ($tmp = @mysqli_commit($link))) printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_errno.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_errno.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_errno.phpt --TEST-- mysqli_connect_errno() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; // too many parameter if (0 !== ($tmp = @mysqli_connect_errno($link))) printf("[001] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (0 !== ($tmp = mysqli_connect_errno())) printf("[003] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); $link = @mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket); if (false !== $link) printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n", $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), $link); if (0 === ($tmp = mysqli_connect_errno())) printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_error.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_error.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_error.phpt --TEST-- mysqli_connect_error() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; // too many parameter if (!is_null($tmp = @mysqli_connect_error($link))) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if ('' !== ($tmp = mysqli_connect_error())) printf("[003] Expecting string/'', got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if ($link = @mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[003] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); if ('' === ($tmp = mysqli_connect_error())) printf("[004] Expecting string/'', got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt --TEST-- new mysqli() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; ini_set('mysqli.default_socket', 'socket'); ini_set('mysqli.default_port', 9999); ini_set('mysqli.default_pw', 'password'); ini_set('mysqli.default_user', 'user'); ini_set('mysqli.default_host', 'host'); mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_STRICT); ini_set('mysqli.default_socket', $socket); try { $mysqli = mysqli_init(); $mysqli->real_connect($host, $user, $passwd, $db, $port); if (!$res = $mysqli->query("SELECT 'mysqli.default_socket' AS testing")) printf("[001] [%d] %s\n", $mysqli->errno, $mysqli->error); var_dump($res->fetch_assoc()); $res->free_result(); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[002] Usage of mysqli.default_socket failed\n"); } ini_set('mysqli.default_port', $port); try { $mysqli = mysqli_init(); $mysqli->real_connect($host, $user, $passwd, $db); if (!$res = $mysqli->query("SELECT 'mysqli.default_port' AS testing")) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); var_dump($res->fetch_assoc()); $res->free_result(); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[004] Usage of mysqli.default_port failed\n"); } ini_set('mysqli.default_pw', $passwd); try { $mysqli = mysqli_init(); $mysqli->real_connect($host, $user); $mysqli->select_db($db); if (!$res = $mysqli->query("SELECT 'mysqli.default_pw' AS testing")) printf("[005] [%d] %s\n", $mysqli->errno, $mysqli->error); var_dump($res->fetch_assoc()); $res->free_result(); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[006] Usage of mysqli.default_pw failed\n"); } ini_set('mysqli.default_user', $user); try { $mysqli = mysqli_init(); $mysqli->real_connect($host); $mysqli->select_db($db); if (!$res = $mysqli->query("SELECT 'mysqli.default_user' AS testing")) printf("[007] [%d] %s\n", $mysqli->errno, $mysqli->error); var_dump($res->fetch_assoc()); $res->free_result(); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[008] Usage of mysqli.default_user failed\n"); } ini_set('mysqli.default_host', $host); try { $mysqli = mysqli_init(); $mysqli->real_connect(); $mysqli->select_db($db); if (!$res = $mysqli->query("SELECT 1")) printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); $res->free_result(); if (!$res = $mysqli->query("SELECT SUBSTRING_INDEX(USER(),'@',1) AS username")) printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); $tmp = $res->fetch_assoc(); $res->free_result(); if ($tmp['username'] !== $user) printf("[011] Expecting string/%s, got %s/%s\n", $user, gettype($tmp['username']), $tmp['username']); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[012] Usage of mysqli.default_host failed\n"); } try { $link = mysqli_connect($host, $user, $passwd, null, ini_get('mysqli.default_port')); mysqli_select_db($link, $db); if (!$res = mysqli_query($link, "SELECT 'have been set' AS all_defaults")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[014] Usage of mysqli_connect() has failed\n"); } try { $link = mysqli_connect($host, $user, $passwd, null); mysqli_select_db($link, $db); if (!$res = mysqli_query($link, "SELECT 'have been set' AS all_defaults")) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[016] Usage of mysqli_connect() has failed\n"); } print "done!"; ?> --EXPECTF-- array(1) { ["testing"]=> string(21) "mysqli.default_socket" } array(1) { ["testing"]=> string(19) "mysqli.default_port" } array(1) { ["testing"]=> string(17) "mysqli.default_pw" } array(1) { ["testing"]=> string(19) "mysqli.default_user" } array(1) { ["all_defaults"]=> string(13) "have been set" } array(1) { ["all_defaults"]=> string(13) "have been set" } done! --UEXPECTF-- array(1) { [u"testing"]=> unicode(21) "mysqli.default_socket" } array(1) { [u"testing"]=> unicode(19) "mysqli.default_port" } array(1) { [u"testing"]=> unicode(17) "mysqli.default_pw" } array(1) { [u"testing"]=> unicode(19) "mysqli.default_user" } array(1) { [u"all_defaults"]=> unicode(13) "have been set" } array(1) { [u"all_defaults"]=> unicode(13) "have been set" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_oo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_oo.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_oo.phpt --TEST-- new mysqli() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; $obj = new stdClass(); if ($mysqli = new mysqli($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket) && !mysqli_connect_errno()) printf("[003] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); if (false !== $mysqli) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($mysqli), $mysqli); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysqli.default_socket', $socket); if (!is_object($mysqli = new mysqli($host, $user, $passwd, $db, $port)) || (0 !== mysqli_connect_errno())) { printf("[005] Usage of mysqli.default_socket failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_port', $port); if (!is_object($mysqli = new mysqli($host, $user, $passwd, $db)) || (0 !== mysqli_connect_errno())) { printf("[006] Usage of mysqli.default_port failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_pw', $passwd); if (!is_object($mysqli = new mysqli($host, $user)) || (0 !== mysqli_connect_errno())) { printf("[007] Usage of mysqli.default_pw failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_user', $user); if (!is_object($mysqli = new mysqli($host)) || (0 !== mysqli_connect_errno())) { printf("[008] Usage of mysqli.default_user failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_host', $host); if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) { printf("[008] Usage of mysqli.default_host failed\n") ; } else { $mysqli->close(); } if ($IS_MYSQLND) { ini_set('mysqli.default_host', 'p:' . $host); if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) { printf("[008b] Usage of mysqli.default_host failed\n") ; } else { $mysqli->close(); } } print "... and now Exceptions\n"; mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_STRICT); try { $mysqli = new mysqli($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket); printf("[016] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); } ini_set('mysqli.default_socket', $socket); try { $mysqli = new mysqli($host, $user, $passwd, $db, $port); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[017] Usage of mysqli.default_socket failed\n") ; } ini_set('mysqli.default_port', $port); try { $mysqli = new mysqli($host, $user, $passwd, $db); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[018] Usage of mysqli.default_port failed\n") ; } ini_set('mysqli.default_pw', $passwd); try { $mysqli = new mysqli($host, $user); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[019] Usage of mysqli.default_pw failed\n"); } ini_set('mysqli.default_user', $user); try { $mysqli = new mysqli($host); $mysqli->close(); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[020] Usage of mysqli.default_user failed\n") ; } ini_set('mysqli.default_host', $host); try { /* NOTE that at this point one must use a different syntax! */ $mysqli = mysqli_init(); $mysqli->real_connect(); assert(0 === mysqli_connect_errno()); $mysqli->close(); assert(0 === mysqli_connect_errno()); } catch (mysqli_sql_exception $e) { printf("%s\n", $e->getMessage()); printf("[021] Usage of mysqli.default_host failed\n"); } print "done!"; ?> --EXPECTF-- Warning: mysqli::mysqli(): (%d/%d): Access denied for user '%sunknown_real'@'%s' (using password: %s) in %s on line %d Warning: mysqli::close(): Couldn't fetch mysqli in %s on line %d.... and now Exceptions Access denied for user '%s'@'%s' (using password: %s) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt --TEST-- new mysqli() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> <?php require_once('skipifnodefuser.inc'); if (stristr(mysqli_get_client_info(), 'mysqlnd')) die("skip: test for libmysql (different error output when using php streams"); ?> --FILE-- <?php include "connect.inc"; $myhost = 'invalidhost'; $link = NULL; print "1) bail\n"; if (!is_object($mysqli = new mysqli($myhost)) || ('mysqli' !== get_class($mysqli))) printf("[001] Expecting NULL, got %s/%s\n", gettype($mysqli), (is_object($mysqli)) ? var_export($mysqli, true) : $mysqli); print "2) be quiet\n"; if (!is_object($mysqli = @new mysqli($myhost)) || ('mysqli' !== get_class($mysqli))) printf("[002] Expecting NULL, got %s/%s\n", gettype($mysqli), (is_object($mysqli)) ? var_export($mysqli, true) : $mysqli); var_dump(mysqli_connect_error()); var_dump(mysqli_connect_errno()); print "3) bail\n"; if (false !== ($link = mysqli_connect($myhost))) { printf("[003] Expecting boolean/false, got %s/%s\n", gettype($link), $link); } print "4) be quiet\n"; if (false !== ($link = @mysqli_connect($myhost))) { printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link); } var_dump(mysqli_connect_error()); var_dump(mysqli_connect_errno()); print "done!"; ?> --EXPECTF-- 1) bail Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host '%s' (1) in %s on line %d 2) be quiet %s(%d) "Unknown MySQL server host '%s' (1)" int(2005) 3) bail Warning: mysqli_connect(): (HY000/2005): Unknown MySQL server host '%s' (1) in %s on line %d 4) be quiet %s(%d) "Unknown MySQL server host '%s' (1)" int(2005) done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect.phpt +++ php-src/ext/mysqli/tests/mysqli_connect.phpt --TEST-- mysqli_connect() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; /* we need to check, if the server allows anonymous login (empty user) */ $tmp = @mysqli_connect('localhost'); $anon_allow = (gettype($tmp) == "object"); $exptype = ($anon_allow) ? "mysqli_object" : "false"; $obj = new stdClass(); if (!is_null($tmp = @mysqli_connect($obj))) printf("[001] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); $tmp = @mysqli_connect($link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[002] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[003] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[004] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link, $link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[005] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link, $link, $link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[006] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } $tmp = @mysqli_connect($link, $link, $link, $link, $link, $link); if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) { printf("[007] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp); } if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[008] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); mysqli_close($link); if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) printf("[009] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $user . 'unknown_really', $db, $port, $socket); if (false !== $link) printf("[010] 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('mysqli.default_socket', $socket); if (!is_object($link = mysqli_connect($host, $user, $passwd, $db, $port))) { printf("[011] Usage of mysqli.default_socket failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_socket' AS 'testing'")) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } ini_set('mysqli.default_port', $port); if (!is_object($link = mysqli_connect($host, $user, $passwd, $db))) { printf("[013] Usage of mysqli.default_port failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_port' AS 'testing'")) printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } ini_set('mysqli.default_pw', $passwd); if (!is_object($link = mysqli_connect($host, $user))) { printf("[015] Usage of mysqli.default_pw failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_pw' AS 'testing'")) printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_assoc($res)); mysqli_free_result($res); mysqli_close($link); } ini_set('mysqli.default_user', $user); if (!is_object($link = mysqli_connect($host))) { printf("[017] Usage of mysqli.default_user failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_user' AS 'testing'")) printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_array($res, MYSQLI_BOTH)); mysqli_free_result($res); mysqli_close($link); } ini_set('mysqli.default_host', $host); if (!is_object($link = mysqli_connect())) { printf("[019] Usage of mysqli.default_host failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host' AS 'testing'")) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump(mysqli_fetch_array($res, MYSQLI_NUM)); mysqli_free_result($res); mysqli_close($link); } if ($IS_MYSQLND) { ini_set('mysqli.default_host', 'p:' . $host); if (!is_object($link = mysqli_connect())) { printf("[021] Usage of mysqli.default_host (persistent) failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { printf("[023] Result looks strange - check manually, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($tmp); } mysqli_free_result($res); mysqli_close($link); } } print "done!"; ?> --EXPECTF-- Warning: mysqli_connect(): (%d/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d array(1) { ["testing"]=> string(21) "mysqli.default_socket" } array(1) { ["testing"]=> string(19) "mysqli.default_port" } array(1) { ["testing"]=> string(17) "mysqli.default_pw" } array(2) { [0]=> string(19) "mysqli.default_user" ["testing"]=> string(19) "mysqli.default_user" } array(1) { [0]=> string(19) "mysqli.default_host" } done! --UEXPECTF-- Warning: mysqli_connect(): (%d/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d array(1) { [u"testing"]=> unicode(21) "mysqli.default_socket" } array(1) { [u"testing"]=> unicode(19) "mysqli.default_port" } array(1) { [u"testing"]=> unicode(17) "mysqli.default_pw" } array(2) { [0]=> unicode(19) "mysqli.default_user" [u"testing"]=> unicode(19) "mysqli.default_user" } array(1) { [0]=> unicode(19) "mysqli.default_host" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_connect_twice.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_connect_twice.phpt +++ php-src/ext/mysqli/tests/mysqli_connect_twice.phpt --TEST-- Calling connect() on an open connection to create a new connection --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$thread_id = mysqli_thread_id($link)) printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0)) printf("[004] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); if ($thread_id == $new_thread_id) printf("[005] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) || !($row = mysqli_fetch_assoc($res))) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($row); mysqli_free_result($res); mysqli_close($link); if (!$link = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (!$thread_id = $link->thread_id) printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket))) printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0)) printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); if ($thread_id == $new_thread_id) printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || !($row = $res->fetch_assoc())) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); var_dump($row); mysqli_free_result($res); mysqli_close($link); if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- array(1) { ["it_works"]=> string(2) "ok" } array(1) { ["syntax"]=> string(18) "works also with oo" } done! --UEXPECTF-- array(1) { [u"it_works"]=> unicode(2) "ok" } array(1) { [u"syntax"]=> unicode(18) "works also with oo" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_constants_categories.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_constants_categories.phpt +++ php-src/ext/mysqli/tests/mysqli_constants_categories.phpt --TEST-- Constants exported by ext/mysqli - checking category - PHP bug not mysqli bug (check from time to time) --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip This hits a known PHP bug, run the test from time to time and enable it once PHP got fixed"); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $constants = get_defined_constants(true); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysqli')) { if ('mysqli' !== $group) printf("found constant '%s' in group '%s'. expecting group 'mysqli'\n", $name, $group); } } } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_constants.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_constants.phpt +++ php-src/ext/mysqli/tests/mysqli_constants.phpt --TEST-- Constants exported by ext/mysqli --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php require("connect.inc"); require("table.inc"); $php_version = (int)str_replace('.', '', PHP_VERSION); $constants = get_defined_constants(true); sort($constants); $expected_constants = array( 'MYSQLI_READ_DEFAULT_GROUP' => true, 'MYSQLI_READ_DEFAULT_FILE' => true, 'MYSQLI_OPT_CONNECT_TIMEOUT' => true, 'MYSQLI_OPT_LOCAL_INFILE' => true, 'MYSQLI_INIT_COMMAND' => true, 'MYSQLI_CLIENT_SSL' => true, "MYSQLI_CLIENT_COMPRESS" => true, "MYSQLI_CLIENT_INTERACTIVE" => true, "MYSQLI_CLIENT_IGNORE_SPACE" => true, "MYSQLI_CLIENT_NO_SCHEMA" => true, "MYSQLI_CLIENT_FOUND_ROWS" => true, "MYSQLI_STORE_RESULT" => true, "MYSQLI_USE_RESULT" => true, "MYSQLI_ASSOC" => true, "MYSQLI_NUM" => true, "MYSQLI_BOTH" => true, "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH" => true, "MYSQLI_NOT_NULL_FLAG" => true, "MYSQLI_PRI_KEY_FLAG" => true, "MYSQLI_UNIQUE_KEY_FLAG" => true, "MYSQLI_MULTIPLE_KEY_FLAG" => true, "MYSQLI_BLOB_FLAG" => true, "MYSQLI_UNSIGNED_FLAG" => true, "MYSQLI_ZEROFILL_FLAG" => true, "MYSQLI_AUTO_INCREMENT_FLAG" => true, "MYSQLI_TIMESTAMP_FLAG" => true, "MYSQLI_SET_FLAG" => true, "MYSQLI_NUM_FLAG" => true, "MYSQLI_PART_KEY_FLAG" => true, "MYSQLI_GROUP_FLAG" => true, "MYSQLI_TYPE_DECIMAL" => true, "MYSQLI_TYPE_TINY" => true, "MYSQLI_TYPE_SHORT" => true, "MYSQLI_TYPE_LONG" => true, "MYSQLI_TYPE_FLOAT" => true, "MYSQLI_TYPE_DOUBLE" => true, "MYSQLI_TYPE_NULL" => true, "MYSQLI_TYPE_TIMESTAMP" => true, "MYSQLI_TYPE_LONGLONG" => true, "MYSQLI_TYPE_INT24" => true, "MYSQLI_TYPE_DATE" => true, "MYSQLI_TYPE_TIME" => true, "MYSQLI_TYPE_DATETIME" => true, "MYSQLI_TYPE_YEAR" => true, "MYSQLI_TYPE_NEWDATE" => true, "MYSQLI_TYPE_ENUM" => true, "MYSQLI_TYPE_SET" => true, "MYSQLI_TYPE_TINY_BLOB" => true, "MYSQLI_TYPE_MEDIUM_BLOB" => true, "MYSQLI_TYPE_LONG_BLOB" => true, "MYSQLI_TYPE_BLOB" => true, "MYSQLI_TYPE_VAR_STRING" => true, "MYSQLI_TYPE_STRING" => true, "MYSQLI_TYPE_CHAR" => true, "MYSQLI_TYPE_INTERVAL" => true, "MYSQLI_TYPE_GEOMETRY" => true, "MYSQLI_NO_DATA" => true, "MYSQLI_REPORT_INDEX" => true, "MYSQLI_REPORT_STRICT" => true, "MYSQLI_REPORT_ALL" => true, "MYSQLI_REPORT_ERROR" => true, "MYSQLI_REPORT_OFF" => true, "MYSQLI_SET_CHARSET_NAME" => true, ); /* depends on the build - experimental */ if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_YEARS_AS_INT')) $expected_constants['MYSQLI_OPT_INT_AND_YEARS_AS_INT'] = true; if ($IS_MYSQLND) { $version = 50007 + 1; } else { $version = mysqli_get_client_version(); } if ($version > 50002) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_TYPE_NEWDECIMAL" => true, "MYSQLI_TYPE_BIT" => true, )); } if ($version > 50003) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_STMT_ATTR_CURSOR_TYPE" => true, "MYSQLI_CURSOR_TYPE_NO_CURSOR" => true, "MYSQLI_CURSOR_TYPE_READ_ONLY" => true, "MYSQLI_CURSOR_TYPE_FOR_UPDATE" => true, "MYSQLI_CURSOR_TYPE_SCROLLABLE" => true, )); } if ($version > 50007) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true, )); } /* pretty dump test, but that is the best way to mimic mysql.c */ if (defined('MYSQLI_DATA_TRUNCATED')) $expected_constants["MYSQLI_DATA_TRUNCATED"] = true; if ($IS_MYSQLND && $php_version >= 600) { /* mysqlnd only */ $expected_constants["MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE"] = true; } else if (!$IS_MYSQLND) { /* libmysql only */ /* are they available in all versions of ext/mysqli ? */ $expected_constants["MYSQLI_RPL_MASTER"] = true; $expected_constants["MYSQLI_RPL_SLAVE"] = true; $expected_constants["MYSQLI_RPL_ADMIN"] = true; } $unexpected_constants = array(); foreach ($constants as $group => $consts) { foreach ($consts as $name => $value) { if (stristr($name, 'mysqli')) { $name = strtoupper($name); if (isset($expected_constants[$name])) { unset($expected_constants[$name]); } else { $unexpected_constants[$name] = $name; } } } } if (!empty($unexpected_constants)) { printf("Dumping list of unexpected constants\n"); var_dump($unexpected_constants); } if (!empty($expected_constants)) { printf("Dumping list of missing constants\n"); var_dump($expected_constants); } print "done!"; ?> --EXPECTF-- done!