xref: /php-src/ext/soap/tests/bugs/bug30928.phpt (revision e1b59e9e)
1--TEST--
2Bug #30928 (When Using WSDL, SoapServer doesn't handle private or protected properties)
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7ini_set("soap.wsdl_cache_enabled", 0);
8
9class foo {
10    public    $a="a";
11    private   $b="b";
12    protected $c="c";
13}
14
15function test($x) {
16  return $x;
17}
18
19class LocalSoapClient extends SoapClient {
20  private $server;
21
22  function __construct($wsdl, $options) {
23    parent::__construct($wsdl, $options);
24    $this->server = new SoapServer($wsdl, $options);
25    $this->server->addFunction('test');
26  }
27
28  function __doRequest($request, $location, $action, $version, $one_way = 0): string {
29    ob_start();
30    $this->server->handle($request);
31    $response = ob_get_contents();
32    ob_end_clean();
33    return $response;
34  }
35}
36
37$x = new LocalSoapClient(__DIR__."/bug30928.wsdl",
38                         array());
39var_dump($x->test(new foo()));
40
41$x = new LocalSoapClient(__DIR__."/bug30928.wsdl",
42                         array("classmap" => array('testType'=>'foo')));
43var_dump($x->test(new foo()));
44
45echo "ok\n";
46?>
47--EXPECTF--
48object(stdClass)#%d (3) {
49  ["a"]=>
50  string(1) "a"
51  ["b"]=>
52  string(1) "b"
53  ["c"]=>
54  string(1) "c"
55}
56object(foo)#%d (3) {
57  ["a"]=>
58  string(1) "a"
59  ["b":"foo":private]=>
60  string(1) "b"
61  ["c":protected]=>
62  string(1) "c"
63}
64ok
65