xref: /PHP-8.1/ext/soap/tests/bugs/bug36999.phpt (revision 8ae4b560)
1--TEST--
2Bug #36999 (xsd:long values clamped to LONG_MAX instead of using double)
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9
10function echoLong($num) {
11  return $num;
12}
13
14class LocalSoapClient extends SoapClient {
15
16  function __construct($wsdl) {
17    parent::__construct($wsdl);
18    $this->server = new SoapServer($wsdl);
19    $this->server->addFunction('echoLong');
20  }
21
22  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
23    ob_start();
24    $this->server->handle($request);
25    $response = ob_get_contents();
26    ob_end_clean();
27    return $response;
28  }
29
30}
31
32$soap = new LocalSoapClient(__DIR__."/bug36999.wsdl");
33
34function test($num) {
35  global $soap;
36  try {
37      printf("%s %0.0f\n", gettype($num), $num);
38      $ret = $soap->echoLong($num);
39      printf("%s %0.0f\n", gettype($ret), $ret);
40    } catch (SoapFault $ex) {
41      var_dump($ex);
42    }
43}
44test(3706790240);
45?>
46--EXPECTF--
47%s 3706790240
48%s 3706790240
49