xref: /php-src/ext/soap/tests/bugs/bug36226.phpt (revision e1b59e9e)
1--TEST--
2Bug #36226 (SOAP Inconsistent handling when passing potential arrays)
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9ini_set("soap.wsdl_cache_enabled",0);
10$timestamp = "2005-11-08T11:22:07+03:00";
11$wsdl = __DIR__."/bug35142.wsdl";
12
13function PostEvents($x) {
14    var_dump($x);
15    exit();
16  return $x;
17}
18
19class TestSoapClient 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('PostEvents');
26  }
27
28  function __doRequest($request, $location, $action, $version, $one_way = 0): string {
29    echo "$request\n";
30    ob_start();
31    $this->server->handle($request);
32    $response = ob_get_contents();
33    ob_end_clean();
34    return $response;
35  }
36
37}
38
39$soapClient = new TestSoapClient($wsdl,
40    array('trace' => 1, 'exceptions' => 0,
41        'classmap' => array('logOnEvent' => 'LogOnEvent',
42            'logOffEvent' => 'LogOffEvent',
43            'events' => 'IVREvents'),
44        'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
45
46$logOnEvent = new LogOnEvent(34567, $timestamp);
47$logOffEvents[] = new LogOffEvent(34567, $timestamp, "Smoked");
48$logOffEvents[] = new LogOffEvent(34568, $timestamp, "SmokeFree");
49$ivrEvents = new IVREvents("1.0", 101, 12345, 'IVR', $logOnEvent, $logOffEvents);
50
51$result = $soapClient->PostEvents($ivrEvents);
52
53class LogOffEvent {
54  public $audienceMemberId;
55  public $timestamp;
56  public $smokeStatus;
57  public $callInitiator;
58
59  function __construct($audienceMemberId, $timestamp, $smokeStatus) {
60    $this->audienceMemberId = $audienceMemberId;
61    $this->timestamp = $timestamp;
62    $this->smokeStatus = $smokeStatus;
63    $this->callInitiator = "IVR";
64  }
65}
66
67class LogOnEvent {
68  public $audienceMemberId;
69  public $timestamp;
70
71  function __construct($audienceMemberId, $timestamp) {
72    $this->audienceMemberId = $audienceMemberId;
73    $this->timestamp = $timestamp;
74  }
75}
76
77class IVREvents {
78  public $version;
79  public $activityId;
80  public $messageId;
81  public $source;
82  public $logOnEvent;
83  public $logOffEvent;
84
85  function __construct($version, $activityId, $messageId, $source, $logOnEvent=NULL, $logOffEvent=NULL) {
86    $this->version = $version;
87    $this->activityId = $activityId;
88    $this->messageId = $messageId;
89    $this->source = $source;
90    $this->logOnEvent = $logOnEvent;
91    $this->logOffEvent = $logOffEvent;
92  }
93}
94?>
95--EXPECTF--
96<?xml version="1.0" encoding="UTF-8"?>
97<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testurl/Message"><SOAP-ENV:Body><ns1:ivrEvents version="1.0" activityId="101" messageId="12345" source="IVR"><ns1:logOffEvent audienceMemberId="34567" timestamp="2005-11-08T11:22:07+03:00" smokeStatus="Smoked" callInitiator="IVR"/><ns1:logOffEvent audienceMemberId="34568" timestamp="2005-11-08T11:22:07+03:00" smokeStatus="SmokeFree" callInitiator="IVR"/><ns1:logOnEvent audienceMemberId="34567" timestamp="2005-11-08T11:22:07+03:00"/></ns1:ivrEvents></SOAP-ENV:Body></SOAP-ENV:Envelope>
98
99object(IVREvents)#%d (6) {
100  ["version"]=>
101  string(3) "1.0"
102  ["activityId"]=>
103  int(101)
104  ["messageId"]=>
105  int(12345)
106  ["source"]=>
107  string(3) "IVR"
108  ["logOnEvent"]=>
109  array(1) {
110    [0]=>
111    object(LogOnEvent)#%d (%d) {
112      ["audienceMemberId"]=>
113      int(34567)
114      ["timestamp"]=>
115      string(25) "2005-11-08T11:22:07+03:00"
116    }
117  }
118  ["logOffEvent"]=>
119  array(2) {
120    [0]=>
121    object(LogOffEvent)#%d (4) {
122      ["audienceMemberId"]=>
123      int(34567)
124      ["timestamp"]=>
125      string(25) "2005-11-08T11:22:07+03:00"
126      ["smokeStatus"]=>
127      string(6) "Smoked"
128      ["callInitiator"]=>
129      string(3) "IVR"
130    }
131    [1]=>
132    object(LogOffEvent)#%d (4) {
133      ["audienceMemberId"]=>
134      int(34568)
135      ["timestamp"]=>
136      string(25) "2005-11-08T11:22:07+03:00"
137      ["smokeStatus"]=>
138      string(9) "SmokeFree"
139      ["callInitiator"]=>
140      string(3) "IVR"
141    }
142  }
143}
144