xref: /PHP-8.2/ext/soap/tests/bugs/bug43045.phpt (revision 8b561d33)
1--TEST--
2Bug #43045i (SOAP encoding violation on "INF" for type double/float)
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7function test($x) {
8  return $x;
9}
10
11class TestSoapClient extends SoapClient {
12  private $server;
13
14  function __construct($wsdl, $options) {
15    parent::__construct($wsdl, $options);
16    $this->server = new SoapServer($wsdl, $options);
17    $this->server->addFunction('test');
18  }
19  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
20    ob_start();
21    $this->server->handle($request);
22    $response = ob_get_contents();
23    ob_end_clean();
24    return $response;
25
26    echo $request;
27    return '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
28xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
29xmlns:xsd="http://www.w3.org/2001/XMLSchema"
30soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
31xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
32<soap:Body><testResponse xmlns="urn:TestSOAP">
33<s-gensym3>
34<doubleInfinity xsi:type="xsd:double">INF</doubleInfinity>
35</s-gensym3>
36</testResponse>
37</soap:Body></soap:Envelope>';
38  }
39}
40$client = new TestSoapClient(NULL, array(
41            "location" => "test://",
42            "uri"      => 'urn:TestSOAP',
43            "style"    => SOAP_RPC,
44            "use"      => SOAP_ENCODED
45            ));
46var_dump($client->test(0.1));
47var_dump($client->test(NAN));
48var_dump($response = $client->test(INF));
49var_dump($response = $client->test(-INF));
50?>
51--EXPECT--
52float(0.1)
53float(NAN)
54float(INF)
55float(-INF)
56