Skip to content

Commit 33f346d

Browse files
author
uw
committed
Improving test to reflect latest API changes
git-svn-id: http://svn.php.net/repository/php/php-src/trunk@318750 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 9f3a6b6 commit 33f346d

File tree

1 file changed

+73
-50
lines changed

1 file changed

+73
-50
lines changed

ext/mysqli/tests/mysqli_class_mysqli_interface.phpt

Lines changed: 73 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ require_once('skipifconnectfailure.inc');
5656
'thread_safe' => true,
5757
'use_result' => true,
5858
);
59+
60+
if (version_compare(PHP_VERSION, '5.3.99', '<=')) {
61+
$expected_methods['client_encoding'] = true;
62+
}
63+
5964
if ($IS_MYSQLND) {
6065
// mysqlnd only
6166
/* $expected_methods['get_client_stats'] = true; */
@@ -94,15 +99,70 @@ require_once('skipifconnectfailure.inc');
9499
printf("ok\n");
95100

96101
printf("\nClass variables:\n");
97-
$variables = array_keys(get_class_vars(get_class($mysqli)));
98-
sort($variables);
99-
foreach ($variables as $k => $var)
100-
printf("%s\n", $var);
102+
103+
$expected_class_variables = $expected_object_variables = array(
104+
"affected_rows" => true,
105+
"client_info" => true,
106+
"client_version" => true,
107+
"connect_errno" => true,
108+
"connect_error" => true,
109+
"errno" => true,
110+
"error" => true,
111+
"field_count" => true,
112+
"host_info" => true,
113+
"info" => true,
114+
"insert_id" => true,
115+
"protocol_version" => true,
116+
"server_info" => true,
117+
"server_version" => true,
118+
"sqlstate" => true,
119+
"stat" => true,
120+
"thread_id" => true,
121+
"warning_count" => true,
122+
);
123+
124+
if (version_compare(PHP_VERSION, '5.3.99', '>')) {
125+
$expected_class_variables["error_list"] = true;
126+
$expected_object_variables["error_list"] = true;
127+
}
128+
129+
$variables = get_class_vars(get_class($mysqli));
130+
foreach ($variables as $var => $v) {
131+
if (isset($expected_class_variables[$var])) {
132+
unset($expected_class_variables[$var]);
133+
unset($variables[$var]);
134+
}
135+
}
136+
137+
if (!empty($expected_class_variables)) {
138+
printf("Dumping list of missing class variables\n");
139+
var_dump($expected_class_variables);
140+
}
141+
if (!empty($variables)) {
142+
printf("Dumping list of unexpected class variables\n");
143+
var_dump($variables);
144+
}
145+
echo "ok\n";
101146

102147
printf("\nObject variables:\n");
103-
$variables = array_keys(get_object_vars($mysqli));
104-
foreach ($variables as $k => $var)
105-
printf("%s\n", $var);
148+
$variables = get_object_vars($mysqli);
149+
foreach ($variables as $var => $v) {
150+
if (isset($expected_object_variables[$var])) {
151+
unset($expected_object_variables[$var]);
152+
unset($variables[$var]);
153+
}
154+
}
155+
156+
if (!empty($expected_object_variables)) {
157+
printf("Dumping list of missing object variables\n");
158+
var_dump($expected_object_variables);
159+
}
160+
if (!empty($variables)) {
161+
printf("Dumping list of unexpected object variables\n");
162+
var_dump($variables);
163+
}
164+
echo "ok\n";
165+
106166

107167
printf("\nMagic, magic properties:\n");
108168

@@ -131,10 +191,10 @@ require_once('skipifconnectfailure.inc');
131191
$mysqli->error, gettype($mysqli->error),
132192
mysqli_error($link), gettype(mysqli_error($link)));
133193

134-
assert(mysqli_error_list($link) === $mysqli->error_list);
135-
printf("mysqli->error_list = '%s'/%s ('%s'/%s)\n",
136-
$mysqli->error_list, gettype($mysqli->error_list),
137-
mysqli_error_list($link), gettype(mysqli_error_list($link)));
194+
if (version_compare(PHP_VERSION, '5.3.99', '>')) {
195+
assert(mysqli_error_list($link) === $mysqli->error_list);
196+
assert(is_array($mysqli->error_list));
197+
}
138198

139199
assert(mysqli_field_count($link) === $mysqli->field_count);
140200
printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n",
@@ -225,54 +285,17 @@ Methods:
225285
ok
226286

227287
Class variables:
228-
affected_rows
229-
client_info
230-
client_version
231-
connect_errno
232-
connect_error
233-
errno
234-
error
235-
error_list
236-
field_count
237-
host_info
238-
info
239-
insert_id
240-
protocol_version
241-
server_info
242-
server_version
243-
sqlstate
244-
stat
245-
thread_id
246-
warning_count
288+
ok
247289

248290
Object variables:
249-
affected_rows
250-
client_info
251-
client_version
252-
connect_errno
253-
connect_error
254-
errno
255-
error
256-
error_list
257-
field_count
258-
host_info
259-
info
260-
insert_id
261-
server_info
262-
server_version
263-
stat
264-
sqlstate
265-
protocol_version
266-
thread_id
267-
warning_count
291+
ok
268292

269293
Magic, magic properties:
270294
mysqli->affected_rows = '%s'/integer ('%s'/integer)
271295
mysqli->client_info = '%s'/%unicode|string% ('%s'/%unicode|string%)
272296
mysqli->client_version = '%d'/integer ('%d'/integer)
273297
mysqli->errno = '0'/integer ('0'/integer)
274298
mysqli->error = ''/%unicode|string% (''/%unicode|string%)
275-
mysqli->error_list = 'Array'/array ('Array'/array)
276299
mysqli->field_count = '0'/integer ('0'/integer)
277300
mysqli->insert_id = '0'/integer ('0'/integer)
278301
mysqli->sqlstate = '00000'/%unicode|string% ('00000'/%unicode|string%)

0 commit comments

Comments
 (0)