From 1eb3bdd802748f52416cb318cfd03c9b7c989730 Mon Sep 17 00:00:00 2001 From: Ulf Wendel Date: Wed, 23 Mar 2011 08:57:52 +0000 Subject: [PATCH] Coverage for a 'silent server protocol change' from the past for which both mysqlnd and libmysql have workarounds. --- ext/mysqli/tests/mysqli_change_user.phpt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ext/mysqli/tests/mysqli_change_user.phpt b/ext/mysqli/tests/mysqli_change_user.phpt index a9b8ae7ade6..bfea423c9e4 100644 --- a/ext/mysqli/tests/mysqli_change_user.phpt +++ b/ext/mysqli/tests/mysqli_change_user.phpt @@ -83,8 +83,28 @@ require_once('skipifconnectfailure.inc'); mysqli_close($link); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + } + + /* silent protocol change if no db which requires workaround in mysqlnd/libmysql + (empty db = no db send with COM_CHANGE_USER) */ + if (true !== ($tmp = mysqli_change_user($link, $user, $passwd, ""))) + printf("[023] Expecting true, got %s/%s\n", gettype($tmp), $tmp); + + if (!$res = mysqli_query($link, 'SELECT database() AS dbname, user() AS user')) + printf("[024] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + mysqli_free_result($res); + + if ($tmp['dbname'] != "") + printf("[025] Expecting database '', got database() '%s'\n", $tmp['dbname']); + + mysqli_close($link); + if (NULL !== ($tmp = @mysqli_change_user($link, $user, $passwd, $db))) - printf("[022] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + printf("[026] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?>