uw Mon, 21 Sep 2009 09:35:23 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=288514
Log:
Fixing mysqli_get_client_stats.phpt. More testing for MYSQLI_INIT_COMMAND
Changed paths:
U
php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_get_client_stats.phpt
U
php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_options_init_command.phpt
U php/php-src/trunk/ext/mysqli/tests/mysqli_get_client_stats.phpt
U php/php-src/trunk/ext/mysqli/tests/mysqli_options_init_command.phpt
Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_get_client_stats.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_get_client_stats.phpt 2009-09-21 09:08:26 UTC (rev 288513)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_get_client_stats.phpt 2009-09-21 09:35:23 UTC (rev 288514)
@@ -840,7 +840,9 @@
mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()');
$info = $new_info;
+ mysqli_close($link);
+
/*
no_index_used
bad_index_used
@@ -885,7 +887,7 @@
mysqli_close($link);
?>
--EXPECTF--
-array(119) {
+array(121) {
[%u|b%"bytes_sent"]=>
%unicode|string%(1) "0"
[%u|b%"bytes_received"]=>
@@ -1124,6 +1126,10 @@
%unicode|string%(1) "0"
[%u|b%"proto_binary_fetched_other"]=>
%unicode|string%(1) "0"
+ [%u|b%"init_command_executed_count"]=>
+ %unicode|string%(1) "0"
+ [%u|b%"init_command_failed_count"]=>
+ %unicode|string%(1) "0"
}
Testing buffered normal...
Testing buffered normal... - SELECT id, label FROM test
Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_options_init_command.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_options_init_command.phpt 2009-09-21 09:08:26 UTC (rev 288513)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_options_init_command.phpt 2009-09-21 09:35:23 UTC (rev 288514)
@@ -1,19 +1,78 @@
--TEST--
mysqli_options()
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
-require_once('skipifemb.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
-
-die("skip - STUB - TODO - this is a stub to remind me that we should also actually test the options");
?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
/* see mysqli.c for details */
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);
+
+ /* TODO: test more options */
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+ !mysqli_query($link, sprintf("CREATE TABLE test(id INT) ENGINE = %s\n", $engine)) ||
+ !mysqli_query($link, "INSERT INTO test(id) VALUES (1)"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!$res = mysqli_query($link, "SELECT COUNT(id) AS _num_rows FROM test"))
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+
+ if ($row['_num_rows'] != 1)
+ printf("[003] Expecting 1 got %s\n", $row['_num_rows']);
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(id) VALUES (2)"))
+ printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!mysqli_real_connect($link, $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 COUNT(id) AS _num_rows FROM test"))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+
+ if ($row['_num_rows'] != 2)
+ printf("[007] Expecting 1 got %s\n", $row['_num_rows']);
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(i_do_no_exist) VALUES (2)"))
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(i_do_no_exist) VALUES (2)"))
+ printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+ printf("[010] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
print "done!";
?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
--EXPECTF--
+Warning: mysqli_real_connect(): (%s/%d): %s in %s on line %d
+[010] Cannot connect to the server using %s
done!
Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_get_client_stats.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/mysqli_get_client_stats.phpt 2009-09-21 09:08:26 UTC (rev 288513)
+++ php/php-src/trunk/ext/mysqli/tests/mysqli_get_client_stats.phpt 2009-09-21 09:35:23 UTC (rev 288514)
@@ -840,7 +840,9 @@
mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()');
$info = $new_info;
+ mysqli_close($link);
+
/*
no_index_used
bad_index_used
@@ -885,7 +887,7 @@
mysqli_close($link);
?>
--EXPECTF--
-array(119) {
+array(121) {
[%u|b%"bytes_sent"]=>
%unicode|string%(1) "0"
[%u|b%"bytes_received"]=>
@@ -1124,6 +1126,10 @@
%unicode|string%(1) "0"
[%u|b%"proto_binary_fetched_other"]=>
%unicode|string%(1) "0"
+ [%u|b%"init_command_executed_count"]=>
+ %unicode|string%(1) "0"
+ [%u|b%"init_command_failed_count"]=>
+ %unicode|string%(1) "0"
}
Testing buffered normal...
Testing buffered normal... - SELECT id, label FROM test
Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_options_init_command.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/mysqli_options_init_command.phpt 2009-09-21 09:08:26 UTC (rev 288513)
+++ php/php-src/trunk/ext/mysqli/tests/mysqli_options_init_command.phpt 2009-09-21 09:35:23 UTC (rev 288514)
@@ -1,19 +1,78 @@
--TEST--
mysqli_options()
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
-require_once('skipifemb.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
-
-die("skip - STUB - TODO - this is a stub to remind me that we should also actually test the options");
?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
/* see mysqli.c for details */
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);
+
+ /* TODO: test more options */
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+ !mysqli_query($link, sprintf("CREATE TABLE test(id INT) ENGINE = %s\n", $engine)) ||
+ !mysqli_query($link, "INSERT INTO test(id) VALUES (1)"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!$res = mysqli_query($link, "SELECT COUNT(id) AS _num_rows FROM test"))
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+
+ if ($row['_num_rows'] != 1)
+ printf("[003] Expecting 1 got %s\n", $row['_num_rows']);
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(id) VALUES (2)"))
+ printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!mysqli_real_connect($link, $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 COUNT(id) AS _num_rows FROM test"))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+
+ if ($row['_num_rows'] != 2)
+ printf("[007] Expecting 1 got %s\n", $row['_num_rows']);
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(i_do_no_exist) VALUES (2)"))
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(i_do_no_exist) VALUES (2)"))
+ printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+ printf("[010] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
print "done!";
?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
--EXPECTF--
+Warning: mysqli_real_connect(): (%s/%d): %s in %s on line %d
+[010] Cannot connect to the server using %s
done!
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php