From c888d69d6797a28813ab5549b7941b94fe8b56f5 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 17 Aug 2024 17:24:18 +0200 Subject: [PATCH 1/3] Drop support for MYSQL_TEST_EXPERIMENTAL 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. --- ext/mysqli/tests/connect.inc | 3 - .../mysqli_class_mysqli_result_interface.phpt | 10 +- ext/mysqli/tests/mysqli_get_warnings.phpt | 141 ------------------ .../tests/mysqli_warning_unclonable.phpt | 18 ++- ext/mysqli/tests/test_setup/test_helpers.inc | 2 - 5 files changed, 13 insertions(+), 161 deletions(-) delete mode 100644 ext/mysqli/tests/mysqli_get_warnings.phpt diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc index 3a7d578e97713..9aee7126b3eb3 100644 --- a/ext/mysqli/tests/connect.inc +++ b/ext/mysqli/tests/connect.inc @@ -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) { diff --git a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt index 5b79f7a197d9a..42cfefa9f1507 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt @@ -130,14 +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"); - } + printf("[009] Expecting ValueError because of invalid resultmode\n"); + } catch (ValueError $ex) {} print "done!"; ?> diff --git a/ext/mysqli/tests/mysqli_get_warnings.phpt b/ext/mysqli/tests/mysqli_get_warnings.phpt deleted file mode 100644 index 55db12d966a92..0000000000000 --- a/ext/mysqli/tests/mysqli_get_warnings.phpt +++ /dev/null @@ -1,141 +0,0 @@ ---TEST-- -mysqli_get_warnings() - TODO ---EXTENSIONS-- -mysqli ---SKIPIF-- - ---FILE-- -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!"; -?> - ---EXPECT-- -done! diff --git a/ext/mysqli/tests/mysqli_warning_unclonable.phpt b/ext/mysqli/tests/mysqli_warning_unclonable.phpt index 7e404563f5df7..8c5732d84673f 100644 --- a/ext/mysqli/tests/mysqli_warning_unclonable.phpt +++ b/ext/mysqli/tests/mysqli_warning_unclonable.phpt @@ -5,8 +5,6 @@ mysqli --SKIPIF-- --FILE-- --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 diff --git a/ext/mysqli/tests/test_setup/test_helpers.inc b/ext/mysqli/tests/test_setup/test_helpers.inc index 7c75034006864..5e6833a3253b9 100644 --- a/ext/mysqli/tests/test_setup/test_helpers.inc +++ b/ext/mysqli/tests/test_setup/test_helpers.inc @@ -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"; From 7a15994ba10fc1a0b58eaefd7d4b1d1a7f4efd92 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 17 Aug 2024 22:03:24 +0200 Subject: [PATCH 2/3] Update ext/mysqli/tests/mysqli_warning_unclonable.phpt Co-authored-by: Kamil Tekiela --- ext/mysqli/tests/mysqli_warning_unclonable.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/mysqli/tests/mysqli_warning_unclonable.phpt b/ext/mysqli/tests/mysqli_warning_unclonable.phpt index 8c5732d84673f..a9da213616144 100644 --- a/ext/mysqli/tests/mysqli_warning_unclonable.phpt +++ b/ext/mysqli/tests/mysqli_warning_unclonable.phpt @@ -27,7 +27,7 @@ require_once 'skipifconnectfailure.inc'; 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($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); + printf("[006] Expecting object/mysqli_warning, got %s/%s\n", gettype($warning), (is_object($warning) ? var_export($warning, true) : $warning)); } $warning_clone = clone $warning; From ea9a0bb9ffe4e7ac6e6afd379e6a79e7fc5ce509 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 18 Aug 2024 00:01:49 +0200 Subject: [PATCH 3/3] Print exception message instead of showing error if there is none --- ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt index 42cfefa9f1507..1a2a6c9718dc0 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt @@ -132,8 +132,9 @@ require_once 'skipifconnectfailure.inc'; try { new mysqli_result($link, $mode); - printf("[009] Expecting ValueError because of invalid resultmode\n"); - } catch (ValueError $ex) {} + } catch (ValueError $ex) { + echo $ex->getMessage(), "\n"; + } print "done!"; ?> @@ -165,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!