xref: /PHP-8.0/ext/soap/tests/bugs/bug38005.phpt (revision f8d79582)
1--TEST--
2Bug #38005 (SoapFault faultstring doesn't follow encoding rules)
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9function Test($param=NULL) {
10    return new SoapFault('Test', 'This is our fault: �');
11}
12
13class TestSoapClient extends SoapClient {
14  function __construct($wsdl, $opt) {
15    parent::__construct($wsdl, $opt);
16    $this->server = new SoapServer($wsdl, $opt);
17    $this->server->addFunction('Test');
18  }
19
20  function __doRequest($request, $location, $action, $version, $one_way = 0) {
21    ob_start();
22    $this->server->handle($request);
23    $response = ob_get_contents();
24    ob_end_clean();
25    return $response;
26  }
27}
28
29$client = new TestSoapClient(NULL, array(
30    'encoding' => 'ISO-8859-1',
31    'uri' => "test://",
32    'location' => "test://",
33    'soap_version'=>SOAP_1_2,
34    'trace'=>1,
35    'exceptions'=>0));
36$res = $client->Test();
37echo($res->faultstring."\n");
38echo($client->__getLastResponse());
39?>
40--EXPECT--
41This is our fault: �
42<?xml version="1.0" encoding="UTF-8"?>
43<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault><env:Code><env:Value>Test</env:Value></env:Code><env:Reason><env:Text>This is our fault: Ä</env:Text></env:Reason></env:Fault></env:Body></env:Envelope>
44