Skip to content

Commit 1451b9e

Browse files
committed
Improve test for mysqli_result constructor
1 parent af4eabd commit 1451b9e

5 files changed

+25
-43
lines changed

ext/mysqli/tests/062.phpt

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
resultset constructor
2+
mysqli_result constructor
33
--EXTENSIONS--
44
mysqli
55
--SKIPIF--
@@ -8,24 +8,39 @@ require_once 'skipifconnectfailure.inc';
88
?>
99
--FILE--
1010
<?php
11-
require_once 'connect.inc';
11+
require_once 'connect.inc';
1212

13-
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
13+
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
1414

15-
$mysql->real_query("SELECT 'foo' FROM DUAL");
15+
$mysqli->real_query("SELECT 'foo' FROM DUAL");
1616

17-
$myresult = new mysqli_result($mysql);
17+
$myresult = new mysqli_result($mysqli);
1818

19-
$row = $myresult->fetch_row();
20-
$myresult->close();
21-
$mysql->close();
19+
$row = $myresult->fetch_row();
20+
$myresult->close();
21+
$mysqli->close();
2222

23-
var_dump($row);
24-
print "done!";
23+
var_dump($row);
24+
25+
try {
26+
new mysqli_result($mysqli);
27+
} catch (Error $exception) {
28+
echo $exception->getMessage() . "\n";
29+
}
30+
31+
$mysqli = new mysqli();
32+
try {
33+
new mysqli_result($mysqli);
34+
} catch (Error $exception) {
35+
echo $exception->getMessage() . "\n";
36+
}
37+
print "done!";
2538
?>
2639
--EXPECT--
2740
array(1) {
2841
[0]=>
2942
string(3) "foo"
3043
}
44+
my_mysqli object is already closed
45+
mysqli object is not fully initialized
3146
done!

ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt

-8
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ require_once 'skipifconnectfailure.inc';
99
--FILE--
1010
<?php
1111
// Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test
12-
$mysqli = new mysqli();
13-
try {
14-
new mysqli_result($mysqli);
15-
} catch (Error $exception) {
16-
echo $exception->getMessage() . "\n";
17-
}
18-
1912
require 'table.inc';
2013
$mysqli = $link;
2114

@@ -54,7 +47,6 @@ require_once 'skipifconnectfailure.inc';
5447
require_once 'clean_table.inc';
5548
?>
5649
--EXPECT--
57-
mysqli object is not fully initialized
5850
[005]
5951
array(2) {
6052
["id"]=>

ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt

-8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ require_once 'skipifconnectfailure.inc';
88
?>
99
--FILE--
1010
<?php
11-
$mysqli = new mysqli();
12-
try {
13-
new mysqli_result($mysqli);
14-
} catch (Error $exception) {
15-
echo $exception->getMessage() . "\n";
16-
}
17-
1811
require 'table.inc';
1912
$mysqli = $link;
2013

@@ -52,7 +45,6 @@ require_once 'skipifconnectfailure.inc';
5245
require_once 'clean_table.inc';
5346
?>
5447
--EXPECTF--
55-
mysqli object is not fully initialized
5648
mysqli_result::fetch_field_direct(): Argument #1 ($index) must be greater than or equal to 0
5749
object(stdClass)#%d (13) {
5850
["name"]=>

ext/mysqli/tests/mysqli_fetch_field_oo.phpt

-9
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ require_once 'skipifconnectfailure.inc';
99
--FILE--
1010
<?php
1111
// Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test
12-
$mysqli = new mysqli();
13-
$res = false;
14-
try {
15-
new mysqli_result($mysqli);
16-
} catch (Error $exception) {
17-
echo $exception->getMessage() . "\n";
18-
}
19-
2012
require 'table.inc';
2113
$mysqli = $link;
2214

@@ -62,7 +54,6 @@ require_once 'skipifconnectfailure.inc';
6254
require_once 'clean_table.inc';
6355
?>
6456
--EXPECTF--
65-
mysqli object is not fully initialized
6657
object(stdClass)#%d (13) {
6758
["name"]=>
6859
string(2) "ID"

ext/mysqli/tests/mysqli_fetch_object_oo.phpt

-8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ require_once 'skipifconnectfailure.inc';
88
?>
99
--FILE--
1010
<?php
11-
$mysqli = new mysqli();
12-
try {
13-
new mysqli_result($mysqli);
14-
} catch (Throwable $e) {
15-
echo $e::class, ': ', $e->getMessage(), "\n";
16-
}
17-
1811
require 'table.inc';
1912
$mysqli = $link;
2013

@@ -123,7 +116,6 @@ require_once 'skipifconnectfailure.inc';
123116
require_once 'clean_table.inc';
124117
?>
125118
--EXPECT--
126-
Error: mysqli object is not fully initialized
127119
Error: Object of class mysqli could not be converted to string
128120
ArgumentCountError: mysqli_result::fetch_object() expects at most 2 arguments, 3 given
129121
TypeError: mysqli_result::fetch_object(): Argument #2 ($constructor_args) must be of type array, null given

0 commit comments

Comments
 (0)