bug36226.phpt 3.8 KB

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