1--TEST-- 2Interface of the class mysqli 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7?> 8--FILE-- 9<?php 10 require('connect.inc'); 11 12 $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); 13 $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); 14 15 printf("Parent class:\n"); 16 var_dump(get_parent_class($mysqli)); 17 18 printf("\nMethods:\n"); 19 $methods = get_class_methods($mysqli); 20 $expected_methods = array( 21 '__construct' => true, 22 'autocommit' => true, 23 'begin_transaction' => true, 24 'change_user' => true, 25 'character_set_name' => true, 26 'close' => true, 27 'commit' => true, 28 'connect' => true, 29 'dump_debug_info' => true, 30 'escape_string' => true, 31 'get_charset' => true, 32 'get_client_info' => true, 33 'get_server_info' => true, 34 'get_warnings' => true, 35 'init' => true, 36 'kill' => true, 37 'more_results' => true, 38 'multi_query' => true, 39 'next_result' => true, 40 'options' => true, 41 'ping' => true, 42 'prepare' => true, 43 'query' => true, 44 'real_connect' => true, 45 'real_escape_string' => true, 46 'real_query' => true, 47 'refresh' => true, 48 'rollback' => true, 49 'release_savepoint' => true, 50 'savepoint' => true, 51 'select_db' => true, 52 'set_charset' => true, 53 'set_opt' => true, 54 'ssl_set' => true, 55 'stat' => true, 56 'stmt_init' => true, 57 'store_result' => true, 58 'thread_safe' => true, 59 'use_result' => true, 60 ); 61 62 if ($IS_MYSQLND) { 63 // mysqlnd only 64 /* $expected_methods['get_client_stats'] = true; */ 65 $expected_methods['get_connection_stats'] = true; 66 $expected_methods['reap_async_query'] = true; 67 $expected_methods['poll'] = true; 68 } 69 70 /* we should add ruled when to expect them */ 71 if (function_exists('mysqli_debug')) 72 $expected_methods['debug'] = true; 73 if (function_exists('ssl_set')) 74 $expected_methods['ssl_set'] = true; 75 76 foreach ($methods as $k => $method) { 77 if (isset($expected_methods[$method])) { 78 unset($methods[$k]); 79 unset($expected_methods[$method]); 80 } 81 } 82 if (!empty($methods)) { 83 printf("Dumping list of unexpected methods.\n"); 84 var_dump($methods); 85 } 86 if (!empty($expected_methods)) { 87 printf("Dumping list of missing methods.\n"); 88 var_dump($expected_methods); 89 } 90 if (empty($methods) && empty($expected_methods)) 91 printf("ok\n"); 92 93 printf("\nClass variables:\n"); 94 95 $expected_class_variables = $expected_object_variables = array( 96 "affected_rows" => true, 97 "client_info" => true, 98 "client_version" => true, 99 "connect_errno" => true, 100 "connect_error" => true, 101 "errno" => true, 102 "error" => true, 103 "field_count" => true, 104 "host_info" => true, 105 "info" => true, 106 "insert_id" => true, 107 "protocol_version" => true, 108 "server_info" => true, 109 "server_version" => true, 110 "sqlstate" => true, 111 "thread_id" => true, 112 "warning_count" => true, 113 ); 114 115 $expected_class_variables["error_list"] = true; 116 $expected_object_variables["error_list"] = true; 117 118 $variables = get_class_vars(get_class($mysqli)); 119 foreach ($variables as $var => $v) { 120 if (isset($expected_class_variables[$var])) { 121 unset($expected_class_variables[$var]); 122 unset($variables[$var]); 123 } 124 } 125 126 if (!empty($expected_class_variables)) { 127 printf("Dumping list of missing class variables\n"); 128 var_dump($expected_class_variables); 129 } 130 if (!empty($variables)) { 131 printf("Dumping list of unexpected class variables\n"); 132 var_dump($variables); 133 } 134 echo "ok\n"; 135 136 printf("\nObject variables:\n"); 137 $variables = get_object_vars($mysqli); 138 foreach ($variables as $var => $v) { 139 if (isset($expected_object_variables[$var])) { 140 unset($expected_object_variables[$var]); 141 unset($variables[$var]); 142 } 143 } 144 145 if (!empty($expected_object_variables)) { 146 printf("Dumping list of missing object variables\n"); 147 var_dump($expected_object_variables); 148 } 149 if (!empty($variables)) { 150 printf("Dumping list of unexpected object variables\n"); 151 var_dump($variables); 152 } 153 echo "ok\n"; 154 155 156 printf("\nMagic, magic properties:\n"); 157 158 assert(mysqli_affected_rows($link) === $mysqli->affected_rows); 159 printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n", 160 $mysqli->affected_rows, gettype($mysqli->affected_rows), 161 mysqli_affected_rows($link), gettype(mysqli_affected_rows($link))); 162 163 assert(mysqli_get_client_info() === $mysqli->client_info); 164 printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n", 165 $mysqli->client_info, gettype($mysqli->client_info), 166 mysqli_get_client_info(), gettype(mysqli_get_client_info())); 167 168 assert(mysqli_get_client_version() === $mysqli->client_version); 169 printf("mysqli->client_version = '%s'/%s ('%s'/%s)\n", 170 $mysqli->client_version, gettype($mysqli->client_version), 171 mysqli_get_client_version(), gettype(mysqli_get_client_version())); 172 173 assert(mysqli_errno($link) === $mysqli->errno); 174 printf("mysqli->errno = '%s'/%s ('%s'/%s)\n", 175 $mysqli->errno, gettype($mysqli->errno), 176 mysqli_errno($link), gettype(mysqli_errno($link))); 177 178 assert(mysqli_error($link) === $mysqli->error); 179 printf("mysqli->error = '%s'/%s ('%s'/%s)\n", 180 $mysqli->error, gettype($mysqli->error), 181 mysqli_error($link), gettype(mysqli_error($link))); 182 183 assert(mysqli_error_list($link) === $mysqli->error_list); 184 assert(is_array($mysqli->error_list)); 185 186 assert(mysqli_field_count($link) === $mysqli->field_count); 187 printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n", 188 $mysqli->field_count, gettype($mysqli->field_count), 189 mysqli_field_count($link), gettype(mysqli_field_count($link))); 190 191 assert(mysqli_insert_id($link) === $mysqli->insert_id); 192 printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n", 193 $mysqli->insert_id, gettype($mysqli->insert_id), 194 mysqli_insert_id($link), gettype(mysqli_insert_id($link))); 195 196 assert(mysqli_sqlstate($link) === $mysqli->sqlstate); 197 printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n", 198 $mysqli->sqlstate, gettype($mysqli->sqlstate), 199 mysqli_sqlstate($link), gettype(mysqli_sqlstate($link))); 200 201 assert(mysqli_get_host_info($link) === $mysqli->host_info); 202 printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n", 203 $mysqli->host_info, gettype($mysqli->host_info), 204 mysqli_get_host_info($link), gettype(mysqli_get_host_info($link))); 205 206 /* note that the data types are different */ 207 assert(mysqli_info($link) == $mysqli->info); 208 printf("mysqli->info = '%s'/%s ('%s'/%s)\n", 209 $mysqli->info, gettype($mysqli->info), 210 mysqli_info($link), gettype(mysqli_info($link))); 211 212 assert(mysqli_thread_id($link) > $mysqli->thread_id); 213 assert(gettype($mysqli->thread_id) == gettype(mysqli_thread_id($link))); 214 printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n", 215 $mysqli->thread_id, gettype($mysqli->thread_id), 216 mysqli_thread_id($link), gettype(mysqli_thread_id($link))); 217 218 assert(mysqli_get_proto_info($link) === $mysqli->protocol_version); 219 printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n", 220 $mysqli->protocol_version, gettype($mysqli->protocol_version), 221 mysqli_get_proto_info($link), gettype(mysqli_get_proto_info($link))); 222 223 assert(mysqli_get_server_info($link) === $mysqli->server_info); 224 printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n", 225 $mysqli->server_info, gettype($mysqli->server_info), 226 mysqli_get_server_info($link), gettype(mysqli_get_server_info($link))); 227 228 assert(mysqli_get_server_version($link) === $mysqli->server_version); 229 printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n", 230 $mysqli->server_version, gettype($mysqli->server_version), 231 mysqli_get_server_version($link), gettype(mysqli_get_server_version($link))); 232 233 assert(mysqli_warning_count($link) === $mysqli->warning_count); 234 printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n", 235 $mysqli->warning_count, gettype($mysqli->warning_count), 236 mysqli_warning_count($link), gettype(mysqli_warning_count($link))); 237 238 printf("\nAccess to undefined properties:\n"); 239 printf("mysqli->unknown = '%s'\n", @$mysqli->unknown); 240 241 @$mysqli->unknown = 13; 242 printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); 243 244 $unknown = 'friday'; 245 @$mysqli->unknown = $unknown; 246 printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); 247 248 $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket); 249 printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n"); 250 assert(mysqli_connect_error() === $mysqli->connect_error); 251 printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", 252 $mysqli->connect_error, gettype($mysqli->connect_error), 253 mysqli_connect_error(), gettype(mysqli_connect_error())); 254 255 assert(mysqli_connect_errno() === $mysqli->connect_errno); 256 printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", 257 $mysqli->connect_errno, gettype($mysqli->connect_errno), 258 mysqli_connect_errno(), gettype(mysqli_connect_errno())); 259 260 print "done!"; 261?> 262--EXPECTF-- 263Parent class: 264bool(false) 265 266Methods: 267ok 268 269Class variables: 270ok 271 272Object variables: 273ok 274 275Magic, magic properties: 276mysqli->affected_rows = '%s'/integer ('%s'/integer) 277mysqli->client_info = '%s'/string ('%s'/string) 278mysqli->client_version = '%d'/integer ('%d'/integer) 279mysqli->errno = '0'/integer ('0'/integer) 280mysqli->error = ''/string (''/string) 281mysqli->field_count = '0'/integer ('0'/integer) 282mysqli->insert_id = '0'/integer ('0'/integer) 283mysqli->sqlstate = '00000'/string ('00000'/string) 284mysqli->host_info = '%s'/string ('%s'/string) 285mysqli->info = ''/NULL (''/NULL) 286mysqli->thread_id = '%d'/integer ('%d'/integer) 287mysqli->protocol_version = '%d'/integer ('%d'/integer) 288mysqli->server_info = '%s'/string ('%s'/string) 289mysqli->server_version = '%d'/integer ('%d'/integer) 290mysqli->warning_count = '0'/integer ('0'/integer) 291 292Access to undefined properties: 293mysqli->unknown = '' 294setting mysqli->unknown, mysqli_unknown = '13' 295setting mysqli->unknown, mysqli_unknown = 'friday' 296 297Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation): 298mysqli->connect_error = ''/NULL (''/NULL) 299mysqli->connect_errno = '0'/integer ('0'/integer) 300done! 301