xref: /PHP-7.4/ext/soap/tests/bugs/bug39815.phpt (revision 782352c5)
1--TEST--
2Bug #39815 (to_zval_double() in ext/soap/php_encoding.c is not locale-independent)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6if (!@setlocale(LC_ALL, 'sv_SE', 'sv_SE.ISO8859-1')) die('skip sv_SE locale not available');
7if (!@setlocale(LC_ALL, 'en_US', 'en_US.ISO8859-1')) die('skip en_US 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
19  function __construct($wsdl, $options) {
20    parent::__construct($wsdl, $options);
21    $this->server = new SoapServer($wsdl, $options);
22    $this->server->addFunction('test');
23  }
24
25  function __doRequest($request, $location, $action, $version, $one_way = 0) {
26    ob_start();
27    $this->server->handle($request);
28    $response = ob_get_contents();
29    ob_end_clean();
30    return $response;
31  }
32
33}
34$x = new LocalSoapClient(NULL,array('location'=>'test://',
35                                   'uri'=>'http://testuri.org',
36                                   "trace"=>1));
37setlocale(LC_ALL,"sv_SE","sv_SE.ISO8859-1");
38var_dump($x->test());
39echo $x->__getLastResponse();
40setlocale(LC_ALL,"en_US","en_US.ISO8859-1");
41var_dump($x->test());
42echo $x->__getLastResponse();
43--EXPECT--
44float(123,456)
45<?xml version="1.0" encoding="UTF-8"?>
46<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>
47float(123.456)
48<?xml version="1.0" encoding="UTF-8"?>
49<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>
50