uw Wed Oct 10 09:55:28 2007 UTC Added files: (Branch: PHP_5_3) /php-src/ext/mysql/tests mysql_max_links.phpt mysql_max_persistent.phpt mysql_num_fields.phpt mysql_num_rows.phpt mysql_pconn_disable.phpt mysql_pconn_kill.phpt mysql_pconn_max_links.phpt mysql_pconn_reuse.phpt mysql_pconnect.phpt mysql_phpinfo.phpt mysql_ping.phpt Log: Second last set of new tests for ext/mysql
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_max_links.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_max_links.phpt +++ php-src/ext/mysql/tests/mysql_max_links.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_max_persistent.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_max_persistent.phpt +++ php-src/ext/mysql/tests/mysql_max_persistent.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_num_fields.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_num_fields.phpt +++ php-src/ext/mysql/tests/mysql_num_fields.phpt --TEST-- mysql_num_fields() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_num_fields())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_num_fields($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); function func_test_mysql_num_fields($link, $query, $expected, $offset, $test_free = false) { if (!($res = mysql_query($query, $link))) { printf("[%03d] [%d] %s\n", $offset, mysql_errno($link), mysql_error($link)); return; } if ($expected !== ($tmp = mysql_num_fields($res))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1, gettype($expected), $expected, gettype($tmp), $tmp); mysql_free_result($res); if ($test_free && (false !== ($tmp = mysql_num_fields($res)))) printf("[%03d] Expecting boolean/false, got %s/%s\n", $offset + 2, gettype($tmp), $tmp); } func_test_mysql_num_fields($link, "SELECT 1 AS a", 1, 5); func_test_mysql_num_fields($link, "SELECT id, label FROM test", 2, 10); func_test_mysql_num_fields($link, "SELECT 1 AS a, NULL AS b, 'foo' AS c", 3, 15); func_test_mysql_num_fields($link, "SELECT id FROM test", 1, 20, true); mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: mysql_num_fields(): %d is not a valid MySQL result resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_num_rows.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_num_rows.phpt +++ php-src/ext/mysql/tests/mysql_num_rows.phpt --TEST-- mysql_num_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 = @mysql_num_rows())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = @mysql_num_rows($link))) printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); function func_test_mysql_num_rows($link, $query, $expected, $offset, $test_free = false) { if (!$res = mysql_query($query, $link)) { printf("[%03d] [%d] %s\n", $offset, mysql_errno($link), mysql_error($link)); return; } if ($expected !== ($tmp = mysql_num_rows($res))) printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1, gettype($expected), $expected, gettype($tmp), $tmp); mysql_free_result($res); if ($test_free && (false !== ($tmp = mysql_num_rows($res)))) printf("[%03d] Expecting boolean/false, got %s/%s\n", $offset + 2, gettype($tmp), $tmp); } func_test_mysql_num_rows($link, "SELECT 1 AS a", 1, 5); func_test_mysql_num_rows($link, "SHOW VARIABLES LIKE '%nixnutz%'", 0, 10); func_test_mysql_num_rows($link, "INSERT INTO test(id, label) VALUES (100, 'z')", false, 15); func_test_mysql_num_rows($link, "SELECT id FROM test LIMIT 2", 2, 20, true); if ($res = mysql_query('SELECT COUNT(id) AS num FROM test', $link)) { $row = mysql_fetch_assoc($res); mysql_free_result($res); func_test_mysql_num_rows($link, "SELECT id, label FROM test", (int)$row['num'], 25); } else { printf("[030] [%d] %s\n", mysql_errno($link), mysql_error($link)); } mysql_close($link); print "done!"; ?> --EXPECTF-- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in %s on line %d Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in %s on line %d Warning: mysql_num_rows(): %d is not a valid MySQL result resource in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_pconn_disable.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_pconn_disable.phpt +++ php-src/ext/mysql/tests/mysql_pconn_disable.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_pconn_kill.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_pconn_kill.phpt +++ php-src/ext/mysql/tests/mysql_pconn_kill.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_pconn_max_links.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_pconn_max_links.phpt +++ php-src/ext/mysql/tests/mysql_pconn_max_links.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_pconn_reuse.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_pconn_reuse.phpt +++ php-src/ext/mysql/tests/mysql_pconn_reuse.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_pconnect.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_pconnect.phpt +++ php-src/ext/mysql/tests/mysql_pconnect.phpt --TEST-- mysql_pconnect() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; // mysql_pconnect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]] ) if (NULL !== ($tmp = @mysql_pconnect($link, $link, $link, $link, $link, $link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $myhost = (is_null($socket)) ? ((is_null($port)) ? $host : $host . ':' . $port) : $host . ':' . $socket; if (!$link = mysql_pconnect($myhost, $user, $passwd, true)) printf("[002] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user, $db, $port, $socket); mysql_close($link); if ($link = mysql_pconnect($myhost, $user . 'unknown_really', $passwd . 'non_empty', true)) printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user . 'unknown_really', $db, $port, $socket); if (false !== $link) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysql.default_socket', $socket); if (!is_resource($link = mysql_pconnect($host, $user, $passwd, true))) { printf("[005] Usage of mysql.default_socket failed\n") ; } else { mysql_close($link); } if (!ini_get('sql.safe_mode')) { ini_set('mysql.default_port', $port); if (!is_resource($link = mysql_pconnect($host, $user, $passwd, true))) { printf("[006] Usage of mysql.default_port failed\n") ; } else { mysql_close($link); } ini_set('mysql.default_password', $passwd); if (!is_resource($link = mysql_pconnect($myhost, $user))) { printf("[007] Usage of mysql.default_password failed\n") ; } else { mysql_close($link); } ini_set('mysql.default_user', $user); if (!is_resource($link = mysql_pconnect($myhost))) { printf("[008] Usage of mysql.default_user failed\n"); } else { mysql_close($link); } ini_set('mysql.default_host', $myhost); if (!is_resource($link = mysql_pconnect())) { printf("[009] Usage of mysql.default_host failed\n") ; } else { mysql_close($link); } } print "done!"; ?> --EXPECTF-- Warning: mysql_pconnect(): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_phpinfo.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_phpinfo.phpt +++ php-src/ext/mysql/tests/mysql_phpinfo.phpt --TEST-- phpinfo() mysql section --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once("connect.inc"); @ob_clean(); ob_start(); phpinfo(); $phpinfo = ob_get_contents(); ob_end_clean(); /* all versions should at least dump this minimum information */ if (!stristr($phpinfo, "mysql support")) printf("[001] ext/mysql should have exposed itself.\n"); if (!stristr($phpinfo, "client api library version")) printf("[002] ext/mysql should have exposed the library version.\n"); if (!stristr($phpinfo, "mysql.default_host")) printf("[003] php.ini setting mysql.default_host not shown.\n"); if (!stristr($phpinfo, "mysql.default_port")) printf("[004] php.ini setting mysql.default_port not shown.\n"); if (!stristr($phpinfo, "mysql.default_password")) printf("[005] php.ini setting mysql.default_password not shown.\n"); if (!stristr($phpinfo, "mysql.default_socket")) printf("[006] php.ini setting mysql.default_socket not shown.\n"); if (!stristr($phpinfo, "mysql.default_user")) printf("[007] php.ini setting mysql.default_user not shown.\n"); if (!stristr($phpinfo, "mysql.max_links")) printf("[008] php.ini setting mysql.max_links not shown.\n"); if (!stristr($phpinfo, "mysql.max_persistent")) printf("[009] php.ini setting mysql.max_persistent not shown.\n"); if (!stristr($phpinfo, "mysql.connect_timeout")) printf("[010] php.ini setting mysql.connect_timeout not shown.\n"); if (!stristr($phpinfo, "mysql.allow_persistent")) printf("[011] php.ini setting mysql.allow_persistent not shown.\n"); if ($IS_MYSQLND) { $expected = array( 'client statistics', 'bytes_sent', 'bytes_received', 'packets_sent', 'packets_received', 'protocol_overhead_in', 'protocol_overhead_out', 'result_set_queries', 'non_result_set_queries', 'no_index_used', 'bad_index_used', 'buffered_sets', 'unbuffered_sets', 'ps_buffered_sets', 'ps_unbuffered_sets', 'flushed_normal_sets', 'flushed_ps_sets', 'rows_fetched_from_server', 'rows_fetched_from_client', 'rows_skipped', 'copy_on_write_saved', 'copy_on_write_performed', 'command_buffer_too_small', 'connect_success', 'connect_failure', 'connection_reused', 'explicit_close', 'implicit_close', 'disconnect_close', 'in_middle_of_command_close', 'explicit_free_result', 'implicit_free_result', 'explicit_stmt_close', 'implicit_stmt_close', 'put_hits', 'put_misses', 'get_hits', 'get_misses', 'size', 'free_items', 'references', 'mysql.cache_size', ); foreach ($expected as $k => $entry) if (!stristr($phpinfo, $entry)) printf("[012] Could not find entry for '%s'\n", $entry); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_ping.phpt?view=markup&rev=1.1 Index: php-src/ext/mysql/tests/mysql_ping.phpt +++ php-src/ext/mysql/tests/mysql_ping.phpt --TEST-- mysql_ping() --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include_once "connect.inc"; $tmp = NULL; $link = NULL; require('table.inc'); if (!is_null($tmp = @mysql_ping($link, $link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); var_dump(mysql_ping($link)); // provoke an error to check if mysql_ping resets it $res = mysql_query('SELECT * FROM unknown_table', $link); if (!($errno = mysql_errno($link))) printf("[002] Statement should have caused an error\n"); var_dump(mysql_ping($link)); if ($errno === mysql_errno($link)) printf("[003] Error codes should have been reset\n"); mysql_close($link); if (false !== ($tmp = mysql_ping($link))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- bool(true) bool(true) Warning: mysql_ping(): %d is not a valid MySQL-Link resource in %s on line %d done!
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php