Commit 0fadb1949a0 for php.net
commit 0fadb1949a021030dcbebcb2a1f042f1a9995a00
Author: NickSdot <32384907+NickSdot@users.noreply.github.com>
Date: Sat Aug 22 19:45:05 2026 +0700
ext/gettext: applied fixers to improve test robustness (#23028)
diff --git a/ext/gettext/tests/44938.phpt b/ext/gettext/tests/44938.phpt
index faaeea6a2a5..3b6727ced56 100644
--- a/ext/gettext/tests/44938.phpt
+++ b/ext/gettext/tests/44938.phpt
@@ -11,108 +11,108 @@
try {
bindtextdomain($overflown, 'path');
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dngettext($overflown, $msgid, $msgid, 1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dngettext($domain, $overflown, $msgid, 1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dngettext($domain, $msgid, $overflown, 1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
gettext($overflown);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
ngettext($overflown, $msgid, -1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
ngettext($msgid, $overflown, -1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dcgettext($overflown, $msgid, -1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dcgettext($domain, $overflown, -1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dcngettext($overflown, $msgid, $msgid, -1, -1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dcngettext($domain, $overflown, $msgid, -1, -1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dcngettext($domain, $msgid, $overflown, -1, -1);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dgettext($overflown, $msgid);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
dgettext($domain, $overflown);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
textdomain($overflown);
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ 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 004ae89409e..b73ca3fb168 100644
--- a/ext/gettext/tests/dcgettext_lcall.phpt
+++ b/ext/gettext/tests/dcgettext_lcall.phpt
@@ -6,16 +6,16 @@
<?php
try {
dcgettext('dngettextTest', 'item', LC_ALL);
-} catch (ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
dcngettext('dngettextTest', 'item', 'item2', 1, LC_ALL);
-} catch (ValueError $e) {
- echo $e->getMessage();
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--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 16258d67801..46950e157c9 100644
--- a/ext/gettext/tests/dcngettext.phpt
+++ b/ext/gettext/tests/dcngettext.phpt
@@ -16,14 +16,14 @@
try {
dcngettext("","","",1,1);
-} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
dcngettext("","","",0,1);
-} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
echo "Done\n";
@@ -33,6 +33,6 @@
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 bba70c9848e..15149deb40a 100644
--- a/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt
+++ b/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt
@@ -6,14 +6,14 @@
<?php
try {
bind_textdomain_codeset(false,false);
- } catch (ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ } catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
bind_textdomain_codeset("", "UTF-8");
- } catch (ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ } catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
// bind_textdomain_codeset() always returns false on musl
@@ -29,8 +29,8 @@
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 607460b3c2d..51ef2d6fd70 100644
--- a/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt
+++ b/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt
@@ -9,13 +9,13 @@
try {
bindtextdomain('', 'foobar');
-} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+ 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 2f2f52d3774..735b08530d6 100644
--- a/ext/gettext/tests/gettext_textdomain-retval.phpt
+++ b/ext/gettext/tests/gettext_textdomain-retval.phpt
@@ -21,22 +21,22 @@
try {
textdomain('0');
-} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
textdomain('');
-} catch (\ValueError $e) {
- echo $e->getMessage();
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--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 836b792bf0d..df3fa634830 100644
--- a/ext/gettext/tests/gh17400.phpt
+++ b/ext/gettext/tests/gh17400.phpt
@@ -11,9 +11,9 @@
try {
bindtextdomain($utf16le_char_bad,$utf16_first_le);
-} catch (\ValueError $e) {
- echo $e->getMessage();
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-bindtextdomain(): Argument #1 ($domain) must not contain any null bytes
+ValueError: bindtextdomain(): Argument #1 ($domain) must not contain any null bytes