xref: /php-src/ext/soap/tests/bugs/bug36226.phpt (revision 8b561d33)
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    $this->server->handle($request);
31    return $response;
32  }
33
34}
35
36$soapClient = new TestSoapClient($wsdl,
37    array('trace' => 1, 'exceptions' => 0,
38        'classmap' => array('logOnEvent' => 'LogOnEvent',
39            'logOffEvent' => 'LogOffEvent',
40            'events' => 'IVREvents'),
41        'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
42
43$logOnEvent = new LogOnEvent(34567, $timestamp);
44$logOffEvents[] = new LogOffEvent(34567, $timestamp, "Smoked");
45$logOffEvents[] = new LogOffEvent(34568, $timestamp, "SmokeFree");
46$ivrEvents = new IVREvents("1.0", 101, 12345, 'IVR', $logOnEvent, $logOffEvents);
47
48$result = $soapClient->PostEvents($ivrEvents);
49
50class LogOffEvent {
51  public $audienceMemberId;
52  public $timestamp;
53  public $smokeStatus;
54  public $callInitiator;
55
56  function __construct($audienceMemberId, $timestamp, $smokeStatus) {
57    $this->audienceMemberId = $audienceMemberId;
58    $this->timestamp = $timestamp;
59    $this->smokeStatus = $smokeStatus;
60    $this->callInitiator = "IVR";
61  }
62}
63
64class LogOnEvent {
65  public $audienceMemberId;
66  public $timestamp;
67
68  function __construct($audienceMemberId, $timestamp) {
69    $this->audienceMemberId = $audienceMemberId;
70    $this->timestamp = $timestamp;
71  }
72}
73
74class IVREvents {
75  public $version;
76  public $activityId;
77  public $messageId;
78  public $source;
79  public $logOnEvent;
80  public $logOffEvent;
81
82  function __construct($version, $activityId, $messageId, $source, $logOnEvent=NULL, $logOffEvent=NULL) {
83    $this->version = $version;
84    $this->activityId = $activityId;
85    $this->messageId = $messageId;
86    $this->source = $source;
87    $this->logOnEvent = $logOnEvent;
88    $this->logOffEvent = $logOffEvent;
89  }
90}
91?>
92--EXPECTF--
93<?xml version="1.0" encoding="UTF-8"?>
94<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>
95
96object(IVREvents)#%d (6) {
97  ["version"]=>
98  string(3) "1.0"
99  ["activityId"]=>
100  int(101)
101  ["messageId"]=>
102  int(12345)
103  ["source"]=>
104  string(3) "IVR"
105  ["logOnEvent"]=>
106  array(1) {
107    [0]=>
108    object(LogOnEvent)#10 (2) {
109      ["audienceMemberId"]=>
110      int(34567)
111      ["timestamp"]=>
112      string(25) "2005-11-08T11:22:07+03:00"
113    }
114  }
115  ["logOffEvent"]=>
116  array(2) {
117    [0]=>
118    object(LogOffEvent)#%d (4) {
119      ["audienceMemberId"]=>
120      int(34567)
121      ["timestamp"]=>
122      string(25) "2005-11-08T11:22:07+03:00"
123      ["smokeStatus"]=>
124      string(6) "Smoked"
125      ["callInitiator"]=>
126      string(3) "IVR"
127    }
128    [1]=>
129    object(LogOffEvent)#%d (4) {
130      ["audienceMemberId"]=>
131      int(34568)
132      ["timestamp"]=>
133      string(25) "2005-11-08T11:22:07+03:00"
134      ["smokeStatus"]=>
135      string(9) "SmokeFree"
136      ["callInitiator"]=>
137      string(3) "IVR"
138    }
139  }
140}
141