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_oo.phpt ('mysqli->change_user()')

Script

1: <?php
2:     
include_once("connect.inc");
3:
4:     
$link    NULL;
5:     
$tmp    NULL;
6:
7:     if (!
$mysqli = new my_mysqli($host$user$passwd$db$port$socket))
8:         
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
9:             
$host$user$db$port$socket);
10:
11:     if (!
is_null($tmp = @$mysqli->change_user()))
12:         
printf("[002] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
13:
14:     if (!
is_null($tmp = @$mysqli->change_user($link)))
15:         
printf("[003] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
16:
17:     if (!
is_null($tmp = @$mysqli->change_user($link$link)))
18:         
printf("[004] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
19:
20:     if (!
is_null($tmp = @$mysqli->change_user($link$link$link$link)))
21:         
printf("[005] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
22:
23:     if (
false !== ($tmp $mysqli->change_user($user '_unknown_really'$passwd 'non_empty'$db)))
24:         
printf("[006] Expecting false, got %s/%s\n"gettype($tmp), $tmp);
25:
26:     if (
false !== ($tmp $mysqli->change_user($user$passwd '_unknown_really'$db)))
27:         
printf("[007] Expecting false, got %s/%s\n"gettype($tmp), $tmp);
28:
29:     if (
false !== ($tmp $mysqli->change_user($user$passwd$db '_unknown_really')))
30:         
printf("[008] Expecting false, got %s/%s\n"gettype($tmp), $tmp);
31:
32:     
// Reconnect because after 3 failed change_user attempts, the server blocks you off.
33:     
if (!$mysqli = new my_mysqli($host$user$passwd$db$port$socket))
34:         
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
35:             
$host$user$db$port$socket);
36:
37:     if (!
$mysqli->query('SET @mysqli_change_user_test_var=1'))
38:         
printf("[009] Failed to set test variable: [%d] %s\n"$mysqli->errno$mysqli->error);
39:
40:     if (!
$res $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var'))
41:         
printf("[010] [%d] %s\n"$mysqli->errno$mysqli->error);
42:     
$tmp $res->fetch_assoc();
43:     
$res->free_result();
44:     if (
!= $tmp['test_var'])
45:         
printf("[011] Cannot set test variable\n");
46:
47:     if (
true !== ($tmp $mysqli->change_user($user$passwd$db)))
48:         
printf("[012] Expecting true, got %s/%s\n"gettype($tmp), $tmp);
49:
50:     if (!
$res $mysqli->query('SELECT database() AS dbname, user() AS user'))
51:         
printf("[013] [%d] %s\n"$mysqli->errno$mysqli->error);
52:     
$tmp $res->fetch_assoc();
53:     
$res->free_result();
54:
55:     if (
substr($tmp['user'], 0strlen($user)) !== $user)
56:         
printf("[014] Expecting user %s, got user() %s\n"$user$tmp['user']);
57:     if (
$tmp['dbname'] != $db)
58:         
printf("[015] Expecting database %s, got database() %s\n"$db$tmp['dbname']);
59:
60:     if (!
$res $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var'))
61:         
printf("[016] [%d] %s\n"$mysqli->errno$mysqli->error);
62:     
$tmp $res->fetch_assoc();
63:     
$res->free_result();
64:     if (
NULL !== $tmp['test_var'])
65:         
printf("[017] Test variable is still set!\n");
66:
67:     
$mysqli->close();
68:
69:     if (
NULL !== ($tmp = @$mysqli->change_user($user$passwd$db)))
70:         
printf("[018] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
71:
72:     print 
"done!";
73:
?>
74:

Expected

done!

Output

[018] Expecting NULL, got boolean/
done!

Diff

001+ [018] 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.