[PHP-CVS] [php-src] master: ext/gettext: applied fixers to improve test robustness (#23028)

[email protected] (NickSdot via GitHub)
Newsgroups php.cvs
Message-ID <[email protected]>
Author: NickSdot (NickSdot)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2026-08-22T13:45:05+01:00

Commit: https://github.com/php/php-src/commit/0fadb1949a021030dcbebcb2a1f042f1a9995a00
Raw diff: https://github.com/php/php-src/commit/0fadb1949a021030dcbebcb2a1f042f1a9995a00.diff

ext/gettext: applied fixers to improve test robustness (#23028)

Changed paths:
  M  ext/gettext/tests/44938.phpt
  M  ext/gettext/tests/dcgettext_lcall.phpt
  M  ext/gettext/tests/dcngettext.phpt
  M  ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt
  M  ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt
  M  ext/gettext/tests/gettext_textdomain-retval.phpt
  M  ext/gettext/tests/gh17400.phpt


Diff:

diff --git a/ext/gettext/tests/44938.phpt b/ext/gettext/tests/44938.phpt
index faaeea6a2a5b..3b6727ced561 100644
--- a/ext/gettext/tests/44938.phpt
+++ b/ext/gettext/tests/44938.phpt
@@ -11,108 +11,108 @@ $category  = "cat";
 
 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 004ae89409ec..b73ca3fb168c 100644
--- a/ext/gettext/tests/dcgettext_lcall.phpt
+++ b/ext/gettext/tests/dcgettext_lcall.phpt
@@ -6,16 +6,16 @@ gettext
 <?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 16258d678015..46950e157c99 100644
--- a/ext/gettext/tests/dcngettext.phpt
+++ b/ext/gettext/tests/dcngettext.phpt
@@ -16,14 +16,14 @@ var_dump(dcngettext("test","test","test",-1,-1));
 
 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(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 bba70c9848e9..15149deb40a6 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 @@ gettext
 <?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 @@ 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..51ef2d6fd704 100644
--- a/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt
+++ b/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt
@@ -9,13 +9,13 @@ chdir(__DIR__);
 
 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, [email protected]
 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..735b08530d63 100644
--- a/ext/gettext/tests/gettext_textdomain-retval.phpt
+++ b/ext/gettext/tests/gettext_textdomain-retval.phpt
@@ -21,22 +21,22 @@ echo textdomain('foo'), "\n";
 
 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, [email protected]
 PHP Testfest Berlin 2009-05-09
diff --git a/ext/gettext/tests/gh17400.phpt b/ext/gettext/tests/gh17400.phpt
index 836b792bf0de..df3fa634830c 100644
--- a/ext/gettext/tests/gh17400.phpt
+++ b/ext/gettext/tests/gh17400.phpt
@@ -11,9 +11,9 @@ $utf16le_char_bad = pack("H*", "00dc00dc");
 
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.