From a2c986dfde76ef59dae2b19b7b58f62e6f5cddfe Mon Sep 17 00:00:00 2001 From: NickSdot Date: Tue, 4 Aug 2026 13:03:14 +0000 Subject: [PATCH] ext/gettext: applied fixers to improve test robustness --- ext/gettext/tests/44938.phpt | 60 +++++++++---------- ext/gettext/tests/dcgettext_lcall.phpt | 8 +-- ext/gettext/tests/dcngettext.phpt | 8 +-- ...ettext_bind_textdomain_codeset-retval.phpt | 8 +-- .../gettext_bindtextdomain-emptydomain.phpt | 4 +- .../tests/gettext_textdomain-retval.phpt | 8 +-- ext/gettext/tests/gh17400.phpt | 4 +- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/ext/gettext/tests/44938.phpt b/ext/gettext/tests/44938.phpt index faaeea6a2a5b..1c80a4618612 100644 --- a/ext/gettext/tests/44938.phpt +++ b/ext/gettext/tests/44938.phpt @@ -12,107 +12,107 @@ $category = "cat"; try { bindtextdomain($overflown, 'path'); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dngettext($overflown, $msgid, $msgid, 1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dngettext($domain, $overflown, $msgid, 1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dngettext($domain, $msgid, $overflown, 1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { gettext($overflown); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { ngettext($overflown, $msgid, -1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { ngettext($msgid, $overflown, -1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dcgettext($overflown, $msgid, -1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dcgettext($domain, $overflown, -1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dcngettext($overflown, $msgid, $msgid, -1, -1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dcngettext($domain, $overflown, $msgid, -1, -1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dcngettext($domain, $msgid, $overflown, -1, -1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dgettext($overflown, $msgid); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { dgettext($domain, $overflown); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { textdomain($overflown); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> --EXPECT-- -bindtextdomain(): Argument #1 ($domain) is too long -dngettext(): Argument #1 ($domain) is too long -dngettext(): Argument #2 ($singular) is too long -dngettext(): Argument #3 ($plural) is too long -gettext(): Argument #1 ($message) is too long -ngettext(): Argument #1 ($singular) is too long -ngettext(): Argument #2 ($plural) is too long -dcgettext(): Argument #1 ($domain) is too long -dcgettext(): Argument #2 ($message) is too long -dcngettext(): Argument #1 ($domain) is too long -dcngettext(): Argument #2 ($singular) is too long -dcngettext(): Argument #3 ($plural) is too long -dgettext(): Argument #1 ($domain) is too long -dgettext(): Argument #2 ($message) is too long -textdomain(): Argument #1 ($domain) is too long +ValueError: bindtextdomain(): Argument #1 ($domain) is too long +ValueError: dngettext(): Argument #1 ($domain) is too long +ValueError: dngettext(): Argument #2 ($singular) is too long +ValueError: dngettext(): Argument #3 ($plural) is too long +ValueError: gettext(): Argument #1 ($message) is too long +ValueError: ngettext(): Argument #1 ($singular) is too long +ValueError: ngettext(): Argument #2 ($plural) is too long +ValueError: dcgettext(): Argument #1 ($domain) is too long +ValueError: dcgettext(): Argument #2 ($message) is too long +ValueError: dcngettext(): Argument #1 ($domain) is too long +ValueError: dcngettext(): Argument #2 ($singular) is too long +ValueError: dcngettext(): Argument #3 ($plural) is too long +ValueError: dgettext(): Argument #1 ($domain) is too long +ValueError: dgettext(): Argument #2 ($message) is too long +ValueError: textdomain(): Argument #1 ($domain) is too long diff --git a/ext/gettext/tests/dcgettext_lcall.phpt b/ext/gettext/tests/dcgettext_lcall.phpt index 004ae89409ec..ddfd5ada1424 100644 --- a/ext/gettext/tests/dcgettext_lcall.phpt +++ b/ext/gettext/tests/dcgettext_lcall.phpt @@ -7,15 +7,15 @@ gettext try { dcgettext('dngettextTest', 'item', LC_ALL); } catch (ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { dcngettext('dngettextTest', 'item', 'item2', 1, LC_ALL); } catch (ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -dcgettext(): Argument #3 ($category) cannot be LC_ALL -dcngettext(): Argument #5 ($category) cannot be LC_ALL +ValueError: dcgettext(): Argument #3 ($category) cannot be LC_ALL +ValueError: dcngettext(): Argument #5 ($category) cannot be LC_ALL diff --git a/ext/gettext/tests/dcngettext.phpt b/ext/gettext/tests/dcngettext.phpt index 16258d678015..e10f952eeaec 100644 --- a/ext/gettext/tests/dcngettext.phpt +++ b/ext/gettext/tests/dcngettext.phpt @@ -17,13 +17,13 @@ var_dump(dcngettext("test","test","test",-1,-1)); try { dcngettext("","","",1,1); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { dcngettext("","","",0,1); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } echo "Done\n"; @@ -33,6 +33,6 @@ string(1) "1" string(4) "test" string(4) "test" string(4) "test" -dcngettext(): Argument #1 ($domain) must not be empty -dcngettext(): Argument #1 ($domain) must not be empty +ValueError: dcngettext(): Argument #1 ($domain) must not be empty +ValueError: dcngettext(): Argument #1 ($domain) must not be empty Done diff --git a/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt b/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt index 44957ad8d700..6b3606924521 100644 --- a/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt +++ b/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt @@ -7,13 +7,13 @@ gettext try { bind_textdomain_codeset(false,false); } catch (ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { bind_textdomain_codeset("", "UTF-8"); } catch (ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } // bind_textdomain_codeset() always returns false on musl @@ -28,8 +28,8 @@ gettext echo "Done\n"; ?> --EXPECT-- -bind_textdomain_codeset(): Argument #1 ($domain) must not be empty -bind_textdomain_codeset(): Argument #1 ($domain) must not be empty +ValueError: bind_textdomain_codeset(): Argument #1 ($domain) must not be empty +ValueError: bind_textdomain_codeset(): Argument #1 ($domain) must not be empty bool(true) Done --CREDITS-- diff --git a/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt b/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt index 607460b3c2db..cdb3ac58ee59 100644 --- a/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt +++ b/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt @@ -10,12 +10,12 @@ chdir(__DIR__); try { bindtextdomain('', 'foobar'); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> --EXPECT-- -bindtextdomain(): Argument #1 ($domain) must not be empty +ValueError: bindtextdomain(): Argument #1 ($domain) must not be empty --CREDITS-- Till Klampaeckel, till@php.net PHP Testfest Berlin 2009-05-09 diff --git a/ext/gettext/tests/gettext_textdomain-retval.phpt b/ext/gettext/tests/gettext_textdomain-retval.phpt index 2f2f52d37743..f9644db3be2b 100644 --- a/ext/gettext/tests/gettext_textdomain-retval.phpt +++ b/ext/gettext/tests/gettext_textdomain-retval.phpt @@ -22,21 +22,21 @@ echo textdomain('foo'), "\n"; try { textdomain('0'); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { textdomain(''); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- test test foo -textdomain(): Argument #1 ($domain) cannot be zero -textdomain(): Argument #1 ($domain) must not be empty +ValueError: textdomain(): Argument #1 ($domain) cannot be zero +ValueError: textdomain(): Argument #1 ($domain) must not be empty --CREDITS-- Christian Weiske, cweiske@php.net PHP Testfest Berlin 2009-05-09 diff --git a/ext/gettext/tests/gh17400.phpt b/ext/gettext/tests/gh17400.phpt index 836b792bf0de..33dc2a0e5d24 100644 --- a/ext/gettext/tests/gh17400.phpt +++ b/ext/gettext/tests/gh17400.phpt @@ -12,8 +12,8 @@ $utf16le_char_bad = pack("H*", "00dc00dc"); try { bindtextdomain($utf16le_char_bad,$utf16_first_le); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -bindtextdomain(): Argument #1 ($domain) must not contain any null bytes +ValueError: bindtextdomain(): Argument #1 ($domain) must not contain any null bytes