diff options
author | Ulf Wendel <uw@php.net> | 2011-03-23 08:57:52 +0000 |
---|---|---|
committer | Ulf Wendel <uw@php.net> | 2011-03-23 08:57:52 +0000 |
commit | 8307f9e89258ed0e5946ca64e5d856b5bef088ac (patch) | |
tree | 6a3f004157f2a0d8e94bdef5d595c8f4b6dfdea7 /ext | |
parent | 5b85234b378668d8ccb5101bde3c3a1a3ca9d238 (diff) | |
download | php-git-8307f9e89258ed0e5946ca64e5d856b5bef088ac.tar.gz |
Coverage for a 'silent server protocol change' from the past for which both mysqlnd and libmysql have workarounds.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/mysqli/tests/mysqli_change_user.phpt | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/ext/mysqli/tests/mysqli_change_user.phpt b/ext/mysqli/tests/mysqli_change_user.phpt index a9b8ae7ade..bfea423c9e 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!"; ?> |