From c8ac9e8519a73fdc5d09fdb98f58fbbcbedf7d73 Mon Sep 17 00:00:00 2001 From: NickSdot Date: Tue, 4 Aug 2026 13:03:14 +0000 Subject: [PATCH] ext/dba: applied fixers to improve test robustness --- ext/dba/tests/dba015.phpt | 4 +- ext/dba/tests/dba_array_keys_errors.phpt | 8 +-- ext/dba/tests/dba_fetch_legacy_signature.phpt | 4 +- ext/dba/tests/dba_flags_arg.phpt | 4 +- ext/dba/tests/gh19885.phpt | 8 +-- ext/dba/tests/value_errors_open.phpt | 64 +++++++++---------- 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/ext/dba/tests/dba015.phpt b/ext/dba/tests/dba015.phpt index a2fa60eb6028..b8979f962df4 100644 --- a/ext/dba/tests/dba015.phpt +++ b/ext/dba/tests/dba015.phpt @@ -48,7 +48,7 @@ var_dump($db_file1); try { dba_exists("key1", $db_file2); } catch (Error $e) { - echo $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "Test 6 - query after closing 2nd object\n"; @@ -75,7 +75,7 @@ This is a test insert 2 Test 5 - close 2nd object object(Dba\Connection)#%d (%d) { } -DBA connection has already been closed +Error: DBA connection has already been closed Test 6 - query after closing 2nd object This is a test insert 1 This is a test insert 2 diff --git a/ext/dba/tests/dba_array_keys_errors.phpt b/ext/dba/tests/dba_array_keys_errors.phpt index d80915c7c318..e9544c8d7176 100644 --- a/ext/dba/tests/dba_array_keys_errors.phpt +++ b/ext/dba/tests/dba_array_keys_errors.phpt @@ -17,12 +17,12 @@ $db = get_any_db($name); try { dba_insert([], "Content String 1", $db); } catch (\Error $e) { - echo $e::class, ': ', $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { dba_insert(["a", "b", "c"], "Content String 2", $db); } catch (\Error $e) { - echo $e::class, ': ', $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } /* Use an object */ @@ -30,12 +30,12 @@ $o = new stdClass(); try { var_dump(dba_insert([$o, 'obj'], 'Test', $db)); } catch (\Error $e) { - echo $e::class, ': ', $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_insert(['group', $o], 'Test', $db)); } catch (\Error $e) { - echo $e::class, ': ', $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } dba_close($db); diff --git a/ext/dba/tests/dba_fetch_legacy_signature.phpt b/ext/dba/tests/dba_fetch_legacy_signature.phpt index 40933f4c76b1..be5f78dd0326 100644 --- a/ext/dba/tests/dba_fetch_legacy_signature.phpt +++ b/ext/dba/tests/dba_fetch_legacy_signature.phpt @@ -24,7 +24,7 @@ set_error_handler(function ($severity, $message, $file, $line) { try { dba_fetch("key1", 0, $db); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } dba_close($db); @@ -41,4 +41,4 @@ Using handler: "%s" Deprecated: Calling dba_fetch() with $dba at the 3rd parameter is deprecated in %s on line %d This is a test insert This is a test insert -Calling dba_fetch() with $dba at the 3rd parameter is deprecated +Exception: Calling dba_fetch() with $dba at the 3rd parameter is deprecated diff --git a/ext/dba/tests/dba_flags_arg.phpt b/ext/dba/tests/dba_flags_arg.phpt index 6a387b51822b..6815f3dec213 100644 --- a/ext/dba/tests/dba_flags_arg.phpt +++ b/ext/dba/tests/dba_flags_arg.phpt @@ -7,8 +7,8 @@ dba try { dba_open('irrelevant', 'c', 'handler', flags: -1); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -dba_open(): Argument #6 ($flags) must be greater than or equal to 0 +ValueError: dba_open(): Argument #6 ($flags) must be greater than or equal to 0 diff --git a/ext/dba/tests/gh19885.phpt b/ext/dba/tests/gh19885.phpt index 987aea4f175a..e6358b3c59b0 100644 --- a/ext/dba/tests/gh19885.phpt +++ b/ext/dba/tests/gh19885.phpt @@ -16,20 +16,20 @@ $db =dba_open($db_file, "r", $handler); try { dba_fetch("1", $db, PHP_INT_MIN); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { dba_fetch("1", $db, PHP_INT_MAX); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } // negative skip needs to remain acceptable albeit corrected down the line var_dump(dba_fetch("1", $db, -1000000)); ?> --EXPECTF-- -dba_fetch(): Argument #3 ($skip) must be between -%d and %d -dba_fetch(): Argument #3 ($skip) must be between -%d and %d +ValueError: dba_fetch(): Argument #3 ($skip) must be between -%d and %d +ValueError: dba_fetch(): Argument #3 ($skip) must be between -%d and %d Notice: dba_fetch(): Handler cdb accepts only skip values greater than or equal to zero, using skip=0 in %s on line %d string(1) "1" diff --git a/ext/dba/tests/value_errors_open.phpt b/ext/dba/tests/value_errors_open.phpt index ee995fe5b8d6..b5472a23d695 100644 --- a/ext/dba/tests/value_errors_open.phpt +++ b/ext/dba/tests/value_errors_open.phpt @@ -21,45 +21,45 @@ var_dump(dba_open($db_file, 'n', 'bogus')); try { var_dump(dba_open('', 'nq')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_open($db_file, '')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_open($db_file, 'nq', '')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_open($db_file, 'q')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_open($db_file, 'nq')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_open($db_file, 'rdq')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_open($db_file, 'n-t')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_open($db_file, 'r', $handler, 0o644, -10)); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } echo '=== Invalid arguments dba_popen() ===', \PHP_EOL; @@ -68,45 +68,45 @@ var_dump(dba_popen($db_file, 'n', 'bogus')); try { var_dump(dba_popen('', 'nq')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_popen($db_file, '')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_popen($db_file, 'nq', '')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_popen($db_file, 'q')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_popen($db_file, 'nq')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_popen($db_file, 'rdq')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_popen($db_file, 'n-t')); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(dba_popen($db_file, 'r', $handler, 0o644, -10)); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --CLEAN-- @@ -121,23 +121,23 @@ object(Dba\Connection)#%d (%d) { Warning: dba_open(): Handler "bogus" is not available in %s on line %d bool(false) -dba_open(): Argument #1 ($path) must not be empty -dba_open(): Argument #2 ($mode) must not be empty -dba_open(): Argument #3 ($handler) must not be empty -dba_open(): Argument #2 ($mode) first character must be one of "r", "w", "c", or "n" -dba_open(): Argument #2 ($mode) second character must be one of "d", "l", "-", or "t" -dba_open(): Argument #2 ($mode) third character must be "t" -dba_open(): Argument #2 ($mode) cannot combine mode "-" (no lock) and "t" (test lock) -dba_open(): Argument #5 ($map_size) must be greater than or equal to 0 +ValueError: dba_open(): Argument #1 ($path) must not be empty +ValueError: dba_open(): Argument #2 ($mode) must not be empty +ValueError: dba_open(): Argument #3 ($handler) must not be empty +ValueError: dba_open(): Argument #2 ($mode) first character must be one of "r", "w", "c", or "n" +ValueError: dba_open(): Argument #2 ($mode) second character must be one of "d", "l", "-", or "t" +ValueError: dba_open(): Argument #2 ($mode) third character must be "t" +ValueError: dba_open(): Argument #2 ($mode) cannot combine mode "-" (no lock) and "t" (test lock) +ValueError: dba_open(): Argument #5 ($map_size) must be greater than or equal to 0 === Invalid arguments dba_popen() === Warning: dba_popen(): Handler "bogus" is not available in %s on line %d bool(false) -dba_popen(): Argument #1 ($path) must not be empty -dba_popen(): Argument #2 ($mode) must not be empty -dba_popen(): Argument #3 ($handler) must not be empty -dba_popen(): Argument #2 ($mode) first character must be one of "r", "w", "c", or "n" -dba_popen(): Argument #2 ($mode) second character must be one of "d", "l", "-", or "t" -dba_popen(): Argument #2 ($mode) third character must be "t" -dba_popen(): Argument #2 ($mode) cannot combine mode "-" (no lock) and "t" (test lock) -dba_popen(): Argument #5 ($map_size) must be greater than or equal to 0 +ValueError: dba_popen(): Argument #1 ($path) must not be empty +ValueError: dba_popen(): Argument #2 ($mode) must not be empty +ValueError: dba_popen(): Argument #3 ($handler) must not be empty +ValueError: dba_popen(): Argument #2 ($mode) first character must be one of "r", "w", "c", or "n" +ValueError: dba_popen(): Argument #2 ($mode) second character must be one of "d", "l", "-", or "t" +ValueError: dba_popen(): Argument #2 ($mode) third character must be "t" +ValueError: dba_popen(): Argument #2 ($mode) cannot combine mode "-" (no lock) and "t" (test lock) +ValueError: dba_popen(): Argument #5 ($map_size) must be greater than or equal to 0