xref: /php-src/ext/soap/tests/bugs/bug39815.phpt (revision 902d6439)
1--TEST--
2Bug #39815 (to_zval_double() in ext/soap/php_encoding.c is not locale-independent)
3--EXTENSIONS--
4soap
5--SKIPIF--
6<?php
7if (!@setlocale(LC_ALL, 'de_DE', 'de_DE.ISO8859-1')) die('skip de_DE locale not available');
8?>
9--INI--
10precision=14
11soap.wsdl_cache_enabled=0
12--FILE--
13<?php
14function test(){
15  return 123.456;
16}
17class LocalSoapClient extends SoapClient {
18  private $server;
19
20  function __construct($wsdl, $options) {
21    parent::__construct($wsdl, $options);
22    $this->server = new SoapServer($wsdl, $options);
23    $this->server->addFunction('test');
24  }
25
26  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
27    ob_start();
28    $this->server->handle($request);
29    $response = ob_get_contents();
30    ob_end_clean();
31    return $response;
32  }
33
34}
35$x = new LocalSoapClient(NULL,array('location'=>'test://',
36                                   'uri'=>'http://testuri.org',
37                                   "trace"=>1));
38setlocale(LC_ALL,"de_DE","de_DE.ISO8859-1");
39var_dump($x->test());
40echo $x->__getLastResponse();
41setlocale(LC_ALL, "C");
42var_dump($x->test());
43echo $x->__getLastResponse();
44?>
45--EXPECT--
46float(123.456)
47<?xml version="1.0" encoding="UTF-8"?>
48<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:testResponse><return xsi:type="xsd:float">123.456</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
49float(123.456)
50<?xml version="1.0" encoding="UTF-8"?>
51<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:testResponse><return xsi:type="xsd:float">123.456</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
52