xref: /PHP-7.1/ext/soap/tests/bugs/bug39815.phpt (revision 7af945e2)
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 (!function_exists('setlocale')) die('skip setlocale() not available');
7if (!@setlocale(LC_ALL, 'sv_SE', 'sv_SE.ISO8859-1')) die('skip sv_SE locale not available');
8if (!@setlocale(LC_ALL, 'en_US', 'en_US.ISO8859-1')) die('skip en_US locale not available');
9?>
10--INI--
11precision=14
12soap.wsdl_cache_enabled=0
13--FILE--
14<?php
15function test(){
16  return 123.456;
17}
18class LocalSoapClient extends SoapClient {
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) {
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,"sv_SE","sv_SE.ISO8859-1");
39var_dump($x->test());
40echo $x->__getLastResponse();
41setlocale(LC_ALL,"en_US","en_US.ISO8859-1");
42var_dump($x->test());
43echo $x->__getLastResponse();
44--EXPECT--
45float(123,456)
46<?xml version="1.0" encoding="UTF-8"?>
47<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>
48float(123.456)
49<?xml version="1.0" encoding="UTF-8"?>
50<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>
51