xref: /PHP-5.3/ext/soap/tests/classmap004.phpt (revision 610c7fbe)
1--TEST--
2SOAP Classmap 4: encoding of objects with __get()
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7ini_set("soap.wsdl_cache_enabled",0);
8
9class A {
10  public $a;
11  function __construct($a){
12    $this->x = $a;
13  }
14  function __get($name) {
15    return @$this->a[$name];
16  }
17  function __set($name, $val) {
18    $this->a[$name] = $val;
19  }
20  function __unset($name) {
21    unset($this->a[$name]);
22  }
23}
24
25class B extends A {
26  function __construct($a){
27    parent::__construct($a);
28    $this->y = $a + 1;
29  }
30}
31
32function f(){
33  return new B(5);
34}
35
36class LocalSoapClient extends SoapClient {
37
38  function __construct($wsdl, $options) {
39    parent::__construct($wsdl, $options);
40    $this->server = new SoapServer($wsdl, $options);
41    $this->server->addFunction("f");
42  }
43
44  function __doRequest($request, $location, $action, $version, $one_way = 0) {
45    ob_start();
46    $this->server->handle($request);
47    $response = ob_get_contents();
48    ob_end_clean();
49    return $response;
50  }
51}
52
53$client = new LocalSoapClient(dirname(__FILE__)."/classmap003.wsdl",
54    array('classmap'=>array('A'=>'A','B'=>'B')));
55print_r($client->f());
56?>
57--EXPECT--
58B Object
59(
60    [a] => Array
61        (
62            [x] => 5
63            [y] => 6
64        )
65
66)
67