bug36226-2.phpt 3.2 KB

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