[php-src] master: ext/soap: applied fixers to improve test robustness (#23031)

NickSdot via GitHub <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: NickSdot (NickSdot)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-08-14T17:20:05+08:00

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

ext/soap: applied fixers to improve test robustness (#23031)

Changed paths:
  M  ext/soap/tests/bugs/bug31755.phpt
  M  ext/soap/tests/bugs/bug42151.phpt
  M  ext/soap/tests/bugs/bug42692.phpt
  M  ext/soap/tests/bugs/bug55639.phpt
  M  ext/soap/tests/bugs/bug71610.phpt
  M  ext/soap/tests/bugs/bug73037.phpt
  M  ext/soap/tests/bugs/bug80672.phpt
  M  ext/soap/tests/bugs/gh16237.phpt
  M  ext/soap/tests/bugs/gh16256.phpt
  M  ext/soap/tests/bugs/gh16429.phpt
  M  ext/soap/tests/bugs/gh22167.phpt
  M  ext/soap/tests/bugs/protocol_relative_redirect.phpt
  M  ext/soap/tests/bugs/relative_redirect.phpt
  M  ext/soap/tests/bugs/relative_redirect_path.phpt
  M  ext/soap/tests/fault_warning.phpt
  M  ext/soap/tests/gh15711.phpt
  M  ext/soap/tests/gh16318.phpt


Diff:

diff --git a/ext/soap/tests/bugs/bug31755.phpt b/ext/soap/tests/bugs/bug31755.phpt
index c4b2c622b6af..2cd623888b55 100644
--- a/ext/soap/tests/bugs/bug31755.phpt
+++ b/ext/soap/tests/bugs/bug31755.phpt
@@ -17,7 +17,7 @@ $client = new MySoapClient(null, array(
 try {
     new SOAPHeader('', 'foo', 'bar');
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 $header = new SOAPHeader('namespace', 'foo', 'bar');
@@ -26,6 +26,6 @@ $response= $client->__soapCall('function', array(), null, $header);
 print $client->__getLastRequest();
 ?>
 --EXPECT--
-SoapHeader::__construct(): Argument #1 ($namespace) must not be empty
+ValueError: SoapHeader::__construct(): Argument #1 ($namespace) must not be empty
 <?xml version="1.0" encoding="UTF-8"?>
 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="myNS" xmlns:ns2="namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><ns2:foo>bar</ns2:foo></SOAP-ENV:Header><SOAP-ENV:Body><ns1:function/></SOAP-ENV:Body></SOAP-ENV:Envelope>
diff --git a/ext/soap/tests/bugs/bug42151.phpt b/ext/soap/tests/bugs/bug42151.phpt
index 2f9c1830ad39..ef8f744b1374 100644
--- a/ext/soap/tests/bugs/bug42151.phpt
+++ b/ext/soap/tests/bugs/bug42151.phpt
@@ -21,12 +21,12 @@ try {
     $bar = new bar();
     $foo = new foo();
 } catch (Exception $e){
-    echo $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 echo "ok\n";
 ?>
 --EXPECTF--
-SOAP-ERROR: Parsing WSDL: Couldn't load from 'httpx://' : failed to load %s
+SoapFault: SOAP-ERROR: Parsing WSDL: Couldn't load from 'httpx://' : failed to load %s
 
 ok
 I don't get executed either.
diff --git a/ext/soap/tests/bugs/bug42692.phpt b/ext/soap/tests/bugs/bug42692.phpt
index fe4840d9268d..78126325ad5c 100644
--- a/ext/soap/tests/bugs/bug42692.phpt
+++ b/ext/soap/tests/bugs/bug42692.phpt
@@ -33,7 +33,7 @@ try {
     $result = $client->checkAuth(1,"two");
     echo "Auth for 1 is $result\n";
 } catch (Exception $e) {
-    echo $e->getMessage();
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 ?>
 --EXPECT--
diff --git a/ext/soap/tests/bugs/bug55639.phpt b/ext/soap/tests/bugs/bug55639.phpt
index 16d7f7a37719..834389361982 100644
--- a/ext/soap/tests/bugs/bug55639.phpt
+++ b/ext/soap/tests/bugs/bug55639.phpt
@@ -44,7 +44,7 @@ $client = new soapclient(NULL, [
 try {
     $client->__soapCall("foo", []);
 } catch (Throwable $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 $headers = $client->__getLastRequestHeaders();
@@ -52,7 +52,7 @@ var_dump($headers);
 
 ?>
 --EXPECTF--
-Unauthorized
+SoapFault: Unauthorized
 string(%d) "POST / HTTP/1.1
 Host: %s
 Connection: Keep-Alive
diff --git a/ext/soap/tests/bugs/bug71610.phpt b/ext/soap/tests/bugs/bug71610.phpt
index f7f674fa0593..34709c5b0693 100644
--- a/ext/soap/tests/bugs/bug71610.phpt
+++ b/ext/soap/tests/bugs/bug71610.phpt
@@ -21,8 +21,8 @@ $exploit = unserialize($ser);
 try {
 $exploit->blahblah();
 } catch(SoapFault $e) {
-    echo $e->getMessage()."\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
-looks like we got no XML document
+SoapFault: looks like we got no XML document
diff --git a/ext/soap/tests/bugs/bug73037.phpt b/ext/soap/tests/bugs/bug73037.phpt
index 7a5b99776772..6d94fca04e0f 100644
--- a/ext/soap/tests/bugs/bug73037.phpt
+++ b/ext/soap/tests/bugs/bug73037.phpt
@@ -175,4 +175,3 @@ Iteration 6
 Function 'CATALOG' doesn't exist
 
 Function 'CATALOG' doesn't exist
-
diff --git a/ext/soap/tests/bugs/bug80672.phpt b/ext/soap/tests/bugs/bug80672.phpt
index 2abc40e39134..d5f54ef6b804 100644
--- a/ext/soap/tests/bugs/bug80672.phpt
+++ b/ext/soap/tests/bugs/bug80672.phpt
@@ -8,8 +8,8 @@ try {
     $client = new SoapClient(__DIR__ . "/bug80672.xml");
     $query = $soap->query(array('sXML' => 'something'));
 } catch(SoapFault $e) {
-    print $e->getMessage();
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 ?>
 --EXPECT--
-SOAP-ERROR: Parsing WSDL: Unexpected WSDL element <>
+SoapFault: SOAP-ERROR: Parsing WSDL: Unexpected WSDL element <>
diff --git a/ext/soap/tests/bugs/gh16237.phpt b/ext/soap/tests/bugs/gh16237.phpt
index 468f2794399e..c86e9c14039d 100644
--- a/ext/soap/tests/bugs/gh16237.phpt
+++ b/ext/soap/tests/bugs/gh16237.phpt
@@ -9,9 +9,9 @@ $server = new SoapServer(null, ['uri'=>"http://testuri.org"]);
 try {
     clone $server;
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
-Trying to clone an uncloneable object of class SoapServer
+Error: Trying to clone an uncloneable object of class SoapServer
diff --git a/ext/soap/tests/bugs/gh16256.phpt b/ext/soap/tests/bugs/gh16256.phpt
index a6d5f3fbbf3c..cefc05c4dd01 100644
--- a/ext/soap/tests/bugs/gh16256.phpt
+++ b/ext/soap/tests/bugs/gh16256.phpt
@@ -11,14 +11,14 @@ $wsdl = __DIR__."/ext/soap/tests/bug41004.wsdl";
 try {
     new SoapClient($wsdl, ["classmap" => $classmap]);
 } catch (Throwable $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     new SoapServer($wsdl, ["classmap" => $classmap]);
 } catch (Throwable $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
-SoapClient::__construct(): Argument #2 ($options) "classmap" option must be an associative array
-SoapServer::__construct(): Argument #2 ($options) "classmap" option must be an associative array
+ValueError: SoapClient::__construct(): Argument #2 ($options) "classmap" option must be an associative array
+ValueError: SoapServer::__construct(): Argument #2 ($options) "classmap" option must be an associative array
diff --git a/ext/soap/tests/bugs/gh16429.phpt b/ext/soap/tests/bugs/gh16429.phpt
index 24d517f96b96..b7073a05b23d 100644
--- a/ext/soap/tests/bugs/gh16429.phpt
+++ b/ext/soap/tests/bugs/gh16429.phpt
@@ -14,9 +14,9 @@ $client = new SoapClient(__DIR__."/../interop/Round2/GroupB/round2_groupB.wsdl",
 try {
     $client->echo2DStringArray($fusion);
 } catch (Exception $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
 string(10) "xxxxxxxxxx"
-Cannot traverse an already closed generator
+Exception: Cannot traverse an already closed generator
diff --git a/ext/soap/tests/bugs/gh22167.phpt b/ext/soap/tests/bugs/gh22167.phpt
index f24bfb0eac32..9a6518d2ad73 100644
--- a/ext/soap/tests/bugs/gh22167.phpt
+++ b/ext/soap/tests/bugs/gh22167.phpt
@@ -98,31 +98,31 @@ foreach ($cases as $name => $schema) {
         new SoapClient($file, ["cache_wsdl" => WSDL_CACHE_NONE]);
         echo "$name: parsed\n";
     } catch (SoapFault $e) {
-        echo "$name: {$e->getMessage()}\n";
+        echo "$name: ", $e::class, ': ', $e->getMessage(), "\n";
     } finally {
         unlink($file);
     }
 }
 ?>
 --EXPECT--
-minOccurs: SOAP-ERROR: Parsing Schema: minOccurs value is out of range
-maxOccurs: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
-negative minOccurs: SOAP-ERROR: Parsing Schema: minOccurs value is out of range
-negative maxOccurs: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
-minExclusive: SOAP-ERROR: Parsing Schema: minExclusive value is out of range
-minInclusive: SOAP-ERROR: Parsing Schema: minInclusive value is out of range
-maxExclusive: SOAP-ERROR: Parsing Schema: maxExclusive value is out of range
-maxInclusive: SOAP-ERROR: Parsing Schema: maxInclusive value is out of range
-totalDigits: SOAP-ERROR: Parsing Schema: totalDigits value is out of range
-fractionDigits: SOAP-ERROR: Parsing Schema: fractionDigits value is out of range
-length: SOAP-ERROR: Parsing Schema: length value is out of range
-minLength: SOAP-ERROR: Parsing Schema: minLength value is out of range
-maxLength: SOAP-ERROR: Parsing Schema: maxLength value is out of range
-leading whitespace numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
-leading plus numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
-leading zero numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
-leading numeric-string with trailing data: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
-negative out-of-range numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
-decimal numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
-exponent numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
+minOccurs: SoapFault: SOAP-ERROR: Parsing Schema: minOccurs value is out of range
+maxOccurs: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
+negative minOccurs: SoapFault: SOAP-ERROR: Parsing Schema: minOccurs value is out of range
+negative maxOccurs: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
+minExclusive: SoapFault: SOAP-ERROR: Parsing Schema: minExclusive value is out of range
+minInclusive: SoapFault: SOAP-ERROR: Parsing Schema: minInclusive value is out of range
+maxExclusive: SoapFault: SOAP-ERROR: Parsing Schema: maxExclusive value is out of range
+maxInclusive: SoapFault: SOAP-ERROR: Parsing Schema: maxInclusive value is out of range
+totalDigits: SoapFault: SOAP-ERROR: Parsing Schema: totalDigits value is out of range
+fractionDigits: SoapFault: SOAP-ERROR: Parsing Schema: fractionDigits value is out of range
+length: SoapFault: SOAP-ERROR: Parsing Schema: length value is out of range
+minLength: SoapFault: SOAP-ERROR: Parsing Schema: minLength value is out of range
+maxLength: SoapFault: SOAP-ERROR: Parsing Schema: maxLength value is out of range
+leading whitespace numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
+leading plus numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
+leading zero numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
+leading numeric-string with trailing data: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
+negative out-of-range numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
+decimal numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
+exponent numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range
 fractional numeric-string within int range: parsed
diff --git a/ext/soap/tests/bugs/protocol_relative_redirect.phpt b/ext/soap/tests/bugs/protocol_relative_redirect.phpt
index e8f30ca66872..e9c30f0ab290 100644
--- a/ext/soap/tests/bugs/protocol_relative_redirect.phpt
+++ b/ext/soap/tests/bugs/protocol_relative_redirect.phpt
@@ -42,7 +42,7 @@ try {
     $client->__soapCall("foo", []);
     echo "redirect followed\n";
 } catch (SoapFault $e) {
-    echo "SoapFault: " . $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
diff --git a/ext/soap/tests/bugs/relative_redirect.phpt b/ext/soap/tests/bugs/relative_redirect.phpt
index 774e7cbd98d7..ebdcd97e5d49 100644
--- a/ext/soap/tests/bugs/relative_redirect.phpt
+++ b/ext/soap/tests/bugs/relative_redirect.phpt
@@ -42,7 +42,7 @@ try {
     $client->__soapCall("foo", []);
     echo "redirect followed\n";
 } catch (SoapFault $e) {
-    echo "SoapFault: " . $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
diff --git a/ext/soap/tests/bugs/relative_redirect_path.phpt b/ext/soap/tests/bugs/relative_redirect_path.phpt
index 09d4c857cc92..2e18c12b926f 100644
--- a/ext/soap/tests/bugs/relative_redirect_path.phpt
+++ b/ext/soap/tests/bugs/relative_redirect_path.phpt
@@ -42,7 +42,7 @@ try {
     $client->__soapCall("foo", []);
     echo "redirect followed\n";
 } catch (SoapFault $e) {
-    echo "SoapFault: " . $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
diff --git a/ext/soap/tests/fault_warning.phpt b/ext/soap/tests/fault_warning.phpt
index 2a9d99fb5dbd..d8c2921a8ef8 100644
--- a/ext/soap/tests/fault_warning.phpt
+++ b/ext/soap/tests/fault_warning.phpt
@@ -8,13 +8,13 @@ soap
 try {
     new SoapFault("", "message"); // Can't be an empty string
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 try {
     new SoapFault(new stdClass(), "message");  // Can't be a non-string (except for null)
 } catch (TypeError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 $fault = new SoapFault("Sender", "message");
@@ -25,13 +25,13 @@ echo get_class($fault) . "\n";
 try {
     new SoapFault(["more"], "message");  // two elements in array required
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 try {
     new SoapFault(["m", "more", "superfluous"], "message"); // two required
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 $fault = new SoapFault(["more-ns", "Sender"], "message");  // two given
@@ -39,10 +39,10 @@ echo get_class($fault);
 
 ?>
 --EXPECT--
-SoapFault::__construct(): Argument #1 ($code) is not a valid fault code
-SoapFault::__construct(): Argument #1 ($code) must be of type array|string|null, stdClass given
+ValueError: SoapFault::__construct(): Argument #1 ($code) is not a valid fault code
+TypeError: SoapFault::__construct(): Argument #1 ($code) must be of type array|string|null, stdClass given
 SoapFault
 SoapFault
-SoapFault::__construct(): Argument #1 ($code) is not a valid fault code
-SoapFault::__construct(): Argument #1 ($code) is not a valid fault code
+ValueError: SoapFault::__construct(): Argument #1 ($code) is not a valid fault code
+ValueError: SoapFault::__construct(): Argument #1 ($code) is not a valid fault code
 SoapFault
diff --git a/ext/soap/tests/gh15711.phpt b/ext/soap/tests/gh15711.phpt
index 17ff051698fd..d3c04d319ab1 100644
--- a/ext/soap/tests/gh15711.phpt
+++ b/ext/soap/tests/gh15711.phpt
@@ -64,7 +64,7 @@ $book->short = NonBackedEnum::First;
 try {
     $client->dotest($book);
 } catch (ValueError $e) {
-    echo "ValueError: ", $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 echo "--- Test with mismatched enum backing type ---\n";
@@ -74,7 +74,7 @@ $book->short = StringBackedEnum::First;
 try {
     $client->dotest($book);
 } catch (ValueError $e) {
-    echo "ValueError: ", $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
diff --git a/ext/soap/tests/gh16318.phpt b/ext/soap/tests/gh16318.phpt
index 0c38b6fc8de3..ce0490d95927 100644
--- a/ext/soap/tests/gh16318.phpt
+++ b/ext/soap/tests/gh16318.phpt
@@ -26,11 +26,11 @@ foreach ([$test1, $test2] as $test) {
     try {
         $client->__soapCall("echoStructArray", array($test), array("soapaction"=>"http://soapinterop.org/","uri"=>"http://soapinterop.org/"));
     } catch (ValueError $e) {
-        echo $e->getMessage(), "\n";
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
 }
 
 ?>
 --EXPECT--
-Recursive array cannot be encoded
-Recursive array cannot be encoded
+ValueError: Recursive array cannot be encoded
+ValueError: Recursive array cannot be encoded
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.