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