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

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

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

ext/xmlwriter: applied fixers to improve test robustness (#23026)

Changed paths:
  M  ext/xmlwriter/tests/010.phpt
  M  ext/xmlwriter/tests/xmlwriter_open_uri_error_001.phpt
  M  ext/xmlwriter/tests/xmlwriter_toMemory_custom_constructor_error.phpt
  M  ext/xmlwriter/tests/xmlwriter_toStream_custom_constructor_error.phpt
  M  ext/xmlwriter/tests/xmlwriter_toStream_open_invalidated_stream.phpt


Diff:

diff --git a/ext/xmlwriter/tests/010.phpt b/ext/xmlwriter/tests/010.phpt
index 29d7d6fa7cee..3d7d310d5fe0 100644
--- a/ext/xmlwriter/tests/010.phpt
+++ b/ext/xmlwriter/tests/010.phpt
@@ -15,16 +15,16 @@ var_dump(xmlwriter_end_attribute($xw));
 
 try {
     xmlwriter_start_attribute($xw, "-1");
-} catch (ValueError $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 var_dump(xmlwriter_end_attribute($xw));
 
 try {
     xmlwriter_start_attribute($xw, "\"");
-} catch (ValueError $e) {
-     echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+     echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 var_dump(xmlwriter_end_attribute($xw));
@@ -45,9 +45,9 @@ echo "Done\n";
 bool(true)
 bool(true)
 bool(true)
-xmlwriter_start_attribute(): Argument #2 ($name) must be a valid attribute name, "-1" given
+ValueError: xmlwriter_start_attribute(): Argument #2 ($name) must be a valid attribute name, "-1" given
 bool(false)
-xmlwriter_start_attribute(): Argument #2 ($name) must be a valid attribute name, """ given
+ValueError: xmlwriter_start_attribute(): Argument #2 ($name) must be a valid attribute name, """ given
 bool(false)
 bool(true)
 string(14) "<tag attr=""/>"
diff --git a/ext/xmlwriter/tests/xmlwriter_open_uri_error_001.phpt b/ext/xmlwriter/tests/xmlwriter_open_uri_error_001.phpt
index 3b136a9be2c8..588c0f7cb2c2 100644
--- a/ext/xmlwriter/tests/xmlwriter_open_uri_error_001.phpt
+++ b/ext/xmlwriter/tests/xmlwriter_open_uri_error_001.phpt
@@ -6,8 +6,8 @@ xmlwriter
 <?php
 try {
     xmlwriter_open_uri('');
-} catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 ?>
 --CREDITS--
@@ -15,4 +15,4 @@ Koen Kuipers [email protected]
 Theo van der Zee
 #Test Fest Utrecht 09-05-2009
 --EXPECT--
-xmlwriter_open_uri(): Argument #1 ($uri) must not be empty
+ValueError: xmlwriter_open_uri(): Argument #1 ($uri) must not be empty
diff --git a/ext/xmlwriter/tests/xmlwriter_toMemory_custom_constructor_error.phpt b/ext/xmlwriter/tests/xmlwriter_toMemory_custom_constructor_error.phpt
index 3a87d963c9d6..935c4d4b481e 100644
--- a/ext/xmlwriter/tests/xmlwriter_toMemory_custom_constructor_error.phpt
+++ b/ext/xmlwriter/tests/xmlwriter_toMemory_custom_constructor_error.phpt
@@ -14,9 +14,9 @@ class CustomXMLWriter extends XMLWriter {
 try {
     CustomXMLWriter::toMemory();
 } catch (Throwable $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
-nope
+Error: nope
diff --git a/ext/xmlwriter/tests/xmlwriter_toStream_custom_constructor_error.phpt b/ext/xmlwriter/tests/xmlwriter_toStream_custom_constructor_error.phpt
index 636d8ffbbc01..f3f0b6856354 100644
--- a/ext/xmlwriter/tests/xmlwriter_toStream_custom_constructor_error.phpt
+++ b/ext/xmlwriter/tests/xmlwriter_toStream_custom_constructor_error.phpt
@@ -16,9 +16,9 @@ $h = fopen("php://output", "w");
 try {
     CustomXMLWriter::toStream($h);
 } catch (Throwable $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
-nope
+Error: nope
diff --git a/ext/xmlwriter/tests/xmlwriter_toStream_open_invalidated_stream.phpt b/ext/xmlwriter/tests/xmlwriter_toStream_open_invalidated_stream.phpt
index b6c6733bb7f8..60736ed1ae09 100644
--- a/ext/xmlwriter/tests/xmlwriter_toStream_open_invalidated_stream.phpt
+++ b/ext/xmlwriter/tests/xmlwriter_toStream_open_invalidated_stream.phpt
@@ -10,10 +10,10 @@ fclose($h);
 
 try {
     XMLWriter::toStream($h);
-} catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
-XMLWriter::toStream(): supplied resource is not a valid stream resource
+TypeError: XMLWriter::toStream(): supplied resource is not a valid stream resource
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.