PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/mysqli/tests/mysqli_change_user_old.phpt ('mysqli_change_user(), MySQL < 5.6')

Script

1: <?php
2:     
require_once("connect.inc");
3:
4:     
$tmp    NULL;
5:     
$link    NULL;
6:
7:     if (!
is_null($tmp = @mysqli_change_user()))
8:         
printf("[001] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
9:
10:     if (!
is_null($tmp = @mysqli_change_user($link)))
11:         
printf("[002] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
12:
13:     if (!
is_null($tmp = @mysqli_change_user($link$link)))
14:         
printf("[003] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
15:
16:     if (!
is_null($tmp = @mysqli_change_user($link$link$link)))
17:         
printf("[004] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
18:
19:     if (!
is_null($tmp = @mysqli_change_user($link$link$link$link$link)))
20:         
printf("[005] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
21:
22:     if (!
$link my_mysqli_connect($host$user$passwd$db$port$socket))
23:         
printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
24:             
$host$user$db$port$socket);
25:
26:     if (
false !== ($tmp mysqli_change_user($link$user '_unknown_really'$passwd 'non_empty'$db)))
27:         
printf("[007] Expecting false, got %s/%s\n"gettype($tmp), $tmp);
28:
29:     if (
false !== ($tmp mysqli_change_user($link$user$passwd '_unknown_really'$db)))
30:         
printf("[008] Expecting false, got %s/%s\n"gettype($tmp), $tmp);
31:
32:     if (
false !== ($tmp mysqli_change_user($link$user$passwd$db '_unknown_really')))
33:         
printf("[009] Expecting false, got %s/%s\n"gettype($tmp), $tmp);
34:
35:     
// Reconnect because Percona and MariaDB block any commands after 3 failed
36:     // change_user commands
37:     
mysqli_close($link);
38:
39:     if (!
$link my_mysqli_connect($host$user$passwd$db$port$socket)) {
40:         
printf("[020] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
41:             
$host$user$db$port$socket);
42:     }
43:     if (!
mysqli_query($link'SET @mysqli_change_user_test_var=1'))
44:         
printf("[010] Failed to set test variable: [%d] %s\n"mysqli_errno($link), mysqli_error($link));
45:
46:     if (!
$res mysqli_query($link'SELECT @mysqli_change_user_test_var AS test_var'))
47:         
printf("[011] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
48:     
$tmp mysqli_fetch_assoc($res);
49:     
mysqli_free_result($res);
50:     if (
!= $tmp['test_var'])
51:         
printf("[012] Cannot set test variable\n");
52:
53:     if (
true !== ($tmp mysqli_change_user($link$user$passwd$db)))
54:         
printf("[013] Expecting true, got %s/%s\n"gettype($tmp), $tmp);
55:
56:     if (!
$res mysqli_query($link'SELECT database() AS dbname, user() AS user'))
57:         
printf("[014] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
58:     
$tmp mysqli_fetch_assoc($res);
59:     
mysqli_free_result($res);
60:
61:     if (
substr($tmp['user'], 0strlen($user)) !== $user)
62:         
printf("[015] Expecting user %s, got user() %s\n"$user$tmp['user']);
63:     if (
$tmp['dbname'] != $db)
64:         
printf("[016] Expecting database %s, got database() %s\n"$db$tmp['dbname']);
65:
66:     if (!
$res mysqli_query($link'SELECT @mysqli_change_user_test_var AS test_var'))
67:         
printf("[017] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
68:     
$tmp mysqli_fetch_assoc($res);
69:     
mysqli_free_result($res);
70:     if (
NULL !== $tmp['test_var'])
71:         
printf("[019] Test variable is still set!\n");
72:
73:     
mysqli_close($link);
74:
75:     if (!
$link my_mysqli_connect($host$user$passwd$db$port$socket)) {
76:         
printf("[020] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
77:             
$host$user$db$port$socket);
78:     }
79:
80:     if (
false !== ($tmp mysqli_change_user($linkstr_repeat('user'16384), str_repeat('pass'16384), str_repeat('dbase'16384))))
81:         
printf("[021] Expecting false, got %s/%s\n"gettype($tmp), $tmp);
82:
83:     
mysqli_close($link);
84:
85:     if (!
$link my_mysqli_connect($host$user$passwd$db$port$socket)) {
86:         
printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
87:             
$host$user$db$port$socket);
88:     }
89:
90:     
/* silent protocol change if no db which requires workaround in mysqlnd/libmysql
91:     (empty db = no db send with COM_CHANGE_USER) */
92:     
if (true !== ($tmp mysqli_change_user($link$user$passwd"")))
93:         
printf("[023] Expecting true, got %s/%s\n"gettype($tmp), $tmp);
94:
95:     if (!
$res mysqli_query($link'SELECT database() AS dbname, user() AS user'))
96:         
printf("[024] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
97:     
$tmp mysqli_fetch_assoc($res);
98:     
mysqli_free_result($res);
99:
100:     if (
$tmp['dbname'] != "")
101:         
printf("[025] Expecting database '', got database() '%s'\n"$tmp['dbname']);
102:
103:     
mysqli_close($link);
104:
105:     if (
NULL !== ($tmp = @mysqli_change_user($link$user$passwd$db)))
106:         
printf("[026] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
107:
108:     print 
"done!";
109:
?>
110:

Expected

done!

Output

[026] Expecting NULL, got boolean/
done!

Diff

001+ [026] Expecting NULL, got boolean/

 

Generated at Mon, 18 Jun 2018 17:33:50 +0000 (4 days ago)

Copyright © 2005-2018 The PHP Group
All rights reserved.