Skip to content

Commit

Permalink
Improve test for mysqli_result constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-tekiela committed Aug 1, 2023
1 parent af4eabd commit 1451b9e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 43 deletions.
35 changes: 25 additions & 10 deletions ext/mysqli/tests/062.phpt
@@ -1,5 +1,5 @@
--TEST--
resultset constructor
mysqli_result constructor
--EXTENSIONS--
mysqli
--SKIPIF--
Expand All @@ -8,24 +8,39 @@ require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
require_once 'connect.inc';

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

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

$myresult = new mysqli_result($mysql);
$myresult = new mysqli_result($mysqli);

$row = $myresult->fetch_row();
$myresult->close();
$mysql->close();
$row = $myresult->fetch_row();
$myresult->close();
$mysqli->close();

var_dump($row);
print "done!";
var_dump($row);

try {
new mysqli_result($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}

$mysqli = new mysqli();
try {
new mysqli_result($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECT--
array(1) {
[0]=>
string(3) "foo"
}
my_mysqli object is already closed
mysqli object is not fully initialized
done!
8 changes: 0 additions & 8 deletions ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt
Expand Up @@ -9,13 +9,6 @@ require_once 'skipifconnectfailure.inc';
--FILE--
<?php
// Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test
$mysqli = new mysqli();
try {
new mysqli_result($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}

require 'table.inc';
$mysqli = $link;

Expand Down Expand Up @@ -54,7 +47,6 @@ require_once 'skipifconnectfailure.inc';
require_once 'clean_table.inc';
?>
--EXPECT--
mysqli object is not fully initialized
[005]
array(2) {
["id"]=>
Expand Down
8 changes: 0 additions & 8 deletions ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt
Expand Up @@ -8,13 +8,6 @@ require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
$mysqli = new mysqli();
try {
new mysqli_result($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}

require 'table.inc';
$mysqli = $link;

Expand Down Expand Up @@ -52,7 +45,6 @@ require_once 'skipifconnectfailure.inc';
require_once 'clean_table.inc';
?>
--EXPECTF--
mysqli object is not fully initialized
mysqli_result::fetch_field_direct(): Argument #1 ($index) must be greater than or equal to 0
object(stdClass)#%d (13) {
["name"]=>
Expand Down
9 changes: 0 additions & 9 deletions ext/mysqli/tests/mysqli_fetch_field_oo.phpt
Expand Up @@ -9,14 +9,6 @@ require_once 'skipifconnectfailure.inc';
--FILE--
<?php
// Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test
$mysqli = new mysqli();
$res = false;
try {
new mysqli_result($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}

require 'table.inc';
$mysqli = $link;

Expand Down Expand Up @@ -62,7 +54,6 @@ require_once 'skipifconnectfailure.inc';
require_once 'clean_table.inc';
?>
--EXPECTF--
mysqli object is not fully initialized
object(stdClass)#%d (13) {
["name"]=>
string(2) "ID"
Expand Down
8 changes: 0 additions & 8 deletions ext/mysqli/tests/mysqli_fetch_object_oo.phpt
Expand Up @@ -8,13 +8,6 @@ require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
$mysqli = new mysqli();
try {
new mysqli_result($mysqli);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

require 'table.inc';
$mysqli = $link;

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

0 comments on commit 1451b9e

Please sign in to comment.