1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Drop support for MYSQL_TEST_EXPERIMENTAL (GH-15467)

This environment variable serves to hide (parts of) tests from general
execution, and as the test failures show when that environment variable
is set, apparently it serves to hide (parts of) test from being
executed at all, thus causing test rot.

To avoid this in the future, we drop `MYSQL_TEST_EXPERIMENTAL`, and fix
the failing tests, except for mysqli_get_warnings.phpt, which appears
to be broken beyond repair, and whose most important tests are already
covered by other test cases.

Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Christoph M. Becker
2024-08-18 11:07:03 +02:00
committed by GitHub
parent 8c704ab401
commit 7fa2dbf924
5 changed files with 13 additions and 159 deletions

View File

@@ -20,9 +20,6 @@
ini_set('mysqli.default_socket', $socket);
}
/* Development setting: test experimental features and/or feature requests that never worked before? */
$TEST_EXPERIMENTAL = 1 == getenv("MYSQL_TEST_EXPERIMENTAL");
function get_environment_connection_flags(): int {
static $connect_flags = null;
if ($connect_flags === null) {

View File

@@ -130,13 +130,10 @@ require_once 'skipifconnectfailure.inc';
$mode = mt_rand(-1000, 1000);
} while (in_array($mode, $valid));
if ($TEST_EXPERIMENTAL) {
ob_start();
try {
new mysqli_result($link, $mode);
$content = ob_get_contents();
ob_end_clean();
if (!stristr($content, 'Invalid value for resultmode'))
printf("[009] Expecting warning because of invalid resultmode\n");
} catch (ValueError $ex) {
echo $ex->getMessage(), "\n";
}
print "done!";
@@ -169,4 +166,5 @@ mysqli_result->unknown = ''
Constructor:
mysqli_result object is already closed
mysqli_result::__construct(): Argument #2 ($result_mode) must be either MYSQLI_STORE_RESULT or MYSQLI_USE_RESULT
done!

View File

@@ -1,141 +0,0 @@
--TEST--
mysqli_get_warnings() - TODO
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
?>
--FILE--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
}
if (false !== ($tmp = mysqli_get_warnings($link))) {
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
}
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "CREATE TABLE test (id SMALLINT)"))
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000)"))
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) {
printf("[008] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_export($tmp, true) : $tmp));
}
if (!method_exists($warning, 'next'))
printf("[009] Borked object, method next is missing\n");
$properties = array_merge(get_object_vars($warning), get_class_vars(get_class($warning)));
if (!empty($properties))
printf("[010] Properties have always been magic, hidden things - why are they visible now, a BC break...\n");
if ((!is_string($warning->message)) || ('' == $warning->message)) /* NULL or not there at all */
printf("[011] Expecting string/not empty, got %s/%s\n", gettype($warning->message), $warning->message);
if ((!is_string($warning->sqlstate)) || ('' == $warning->sqlstate)) /* NULL or not there at all */
printf("[012] Expecting string/not empty, got %s/%s\n", gettype($warning->sqlstate), $warning->sqlstate);
if ((!is_int($warning->errno)) || (0 == $warning->errno)) /* NULL or not there at all */
printf("[013] Expecting int/not 0, got %s/%s\n", gettype($warning->errno), $warning->errno);
if (false !== ($tmp = $warning->next()))
printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000), (1000001)"))
printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (($tmp = mysqli_warning_count($link)) !== 2)
printf("[016] Expecting 2 warnings, got %d warnings", $tmp);
if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) {
printf("[017] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_export($tmp, true) : $tmp));
}
if (true !== ($tmp = $warning->next()))
printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
if (false !== ($tmp = $warning->next()))
printf("[020] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
mysqli_close($link);
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
if (!$mysqli->query("DROP TABLE IF EXISTS t1"))
printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$mysqli->query("CREATE TABLE t1 (a smallint)"))
printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$warning = new mysqli_warning($mysqli);
if (!is_string($warning->message) || ('' == $warning->message))
printf("[025] Expecting string, got %s/%s", gettype($warning->message), $warning->message);
if (!$mysqli->query("DROP TABLE t1"))
printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
/* Yes, I really want to check if the object property is empty */
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$warning = new mysqli_warning($mysqli);
if (false !== ($tmp = $warning->next()))
printf("[028] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if ('' != ($tmp = $warning->message))
printf("[029] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp);
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
if (!$mysqli->query("DROP TABLE IF EXISTS t1"))
printf("[031] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$mysqli->query("CREATE TABLE t1 (a smallint)"))
printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
/* out of range, three warnings */
if (!$mysqli->query("INSERT IGNORE INTO t1(a) VALUES (65536), (65536), (65536)"))
printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$warning = new mysqli_warning($mysqli);
$i = 1;
while ($warning->next() && ('' != ($tmp = $warning->message))) {
$i++;
}
if (3 != $i)
printf("[034] Expecting three warnings, got %d warnings\n", $i);
$stmt = mysqli_stmt_init($mysqli);
$warning = new mysqli_warning($stmt);
if (false !== ($tmp = $warning->next()))
printf("[035] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
print "done!";
?>
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS t1"))
printf("[c003] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
done!

View File

@@ -5,8 +5,6 @@ mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
?>
--FILE--
<?php
@@ -16,15 +14,18 @@ if (!$TEST_EXPERIMENTAL)
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[002] Cannot set SQL-Mode, [%d] %s\n", mysqli_errno($mysql), mysqli_error($mysql));
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "CREATE TABLE test (id SMALLINT)"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000)"))
if (!mysqli_query($link, "CREATE TABLE test (id SMALLINT NOT NULL)"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1), (NULL)"))
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) {
printf("[006] Expecting object/mysqli_warning, got %s/%s\n", gettype($warning), (is_object($warning) ? var_export($warning, true) : $warning));
}
@@ -37,4 +38,5 @@ if (!$TEST_EXPERIMENTAL)
require_once 'clean_table.inc';
?>
--EXPECTF--
Fatal error: Trying to clone an uncloneable object of class mysqli_warning in %s on line %d
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_warning in %s:%d
Stack trace:%A

View File

@@ -142,6 +142,4 @@ function setup_table_with_data_on_default_connection(string $table): mysqli {
return $link;
}
/* Development setting: test experimental features and/or feature requests that never worked before? */
//$TEST_EXPERIMENTAL = 1 == getenv("MYSQL_TEST_EXPERIMENTAL");
//$engine = getenv("MYSQL_TEST_ENGINE") ?: "InnoDB";