PageRenderTime 58ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/Zend/Soap/AutoDiscoverTest.php

https://github.com/damoon/zf
PHP | 907 lines | 710 code | 106 blank | 91 comment | 2 complexity | 6a0cd27cf41286d15b9a4802d4e0a033 MD5 | raw file
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Soap
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once dirname(__FILE__)."/../../TestHelper.php";
  23. /** PHPUnit Test Case */
  24. require_once 'PHPUnit/Framework/TestCase.php';
  25. /** Zend_Soap_AutoDiscover */
  26. require_once 'Zend/Soap/AutoDiscover.php';
  27. /** Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex */
  28. require_once "Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php";
  29. /** Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence */
  30. require_once "Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php";
  31. /** Include Common TestTypes */
  32. require_once "_files/commontypes.php";
  33. /**
  34. * Test cases for Zend_Soap_AutoDiscover
  35. *
  36. * @category Zend
  37. * @package Zend_Soap
  38. * @subpackage UnitTests
  39. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. * @group Zend_Soap
  42. */
  43. class Zend_Soap_AutoDiscoverTest extends PHPUnit_Framework_TestCase
  44. {
  45. public function setUp()
  46. {
  47. // This has to be done because some CLI setups don't have $_SERVER variables
  48. // to simuulate that we have an actual webserver.
  49. if(!isset($_SERVER) || !is_array($_SERVER)) {
  50. $_SERVER = array();
  51. }
  52. $_SERVER['HTTP_HOST'] = 'localhost';
  53. $_SERVER['REQUEST_URI'] = '/my_script.php?wsdl';
  54. $_SERVER['SCRIPT_NAME'] = '/my_script.php';
  55. $_SERVER['HTTPS'] = "off";
  56. }
  57. protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring)
  58. {
  59. $xmlstring = str_replace(array("\r", "\n"), "", $xmlstring);
  60. $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring);
  61. return $xmlstring;
  62. }
  63. function testSetClass()
  64. {
  65. $scriptUri = 'http://localhost/my_script.php';
  66. $server = new Zend_Soap_AutoDiscover();
  67. $server->setClass('Zend_Soap_AutoDiscover_Test');
  68. $dom = new DOMDocument();
  69. ob_start();
  70. $server->handle();
  71. $dom->loadXML(ob_get_clean());
  72. $wsdl = '<?xml version="1.0"?>'
  73. . '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
  74. . 'xmlns:tns="' . $scriptUri . '" '
  75. . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
  76. . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
  77. . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
  78. . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
  79. . 'name="Zend_Soap_AutoDiscover_Test" '
  80. . 'targetNamespace="' . $scriptUri . '">'
  81. . '<types>'
  82. . '<xsd:schema targetNamespace="' . $scriptUri . '"/>'
  83. . '</types>'
  84. . '<portType name="Zend_Soap_AutoDiscover_TestPort">'
  85. . '<operation name="testFunc1">'
  86. . '<documentation>Test Function 1</documentation>'
  87. . '<input message="tns:testFunc1In"/>'
  88. . '<output message="tns:testFunc1Out"/>'
  89. . '</operation>'
  90. . '<operation name="testFunc2">'
  91. . '<documentation>Test Function 2</documentation>'
  92. . '<input message="tns:testFunc2In"/>'
  93. . '<output message="tns:testFunc2Out"/>'
  94. . '</operation>'
  95. . '<operation name="testFunc3">'
  96. . '<documentation>Test Function 3</documentation>'
  97. . '<input message="tns:testFunc3In"/>'
  98. . '<output message="tns:testFunc3Out"/>'
  99. . '</operation><operation name="testFunc4">'
  100. . '<documentation>Test Function 4</documentation>'
  101. . '<input message="tns:testFunc4In"/>'
  102. . '<output message="tns:testFunc4Out"/>'
  103. . '</operation>'
  104. . '</portType>'
  105. . '<binding name="Zend_Soap_AutoDiscover_TestBinding" type="tns:Zend_Soap_AutoDiscover_TestPort">'
  106. . '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>'
  107. . '<operation name="testFunc1">'
  108. . '<soap:operation soapAction="' . $scriptUri . '#testFunc1"/>'
  109. . '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'
  110. . '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'
  111. . '</operation>'
  112. . '<operation name="testFunc2">'
  113. . '<soap:operation soapAction="' . $scriptUri . '#testFunc2"/>'
  114. . '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'
  115. . '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'
  116. . '</operation>'
  117. . '<operation name="testFunc3">'
  118. . '<soap:operation soapAction="' . $scriptUri . '#testFunc3"/>'
  119. . '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'
  120. . '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'
  121. . '</operation>'
  122. . '<operation name="testFunc4">'
  123. . '<soap:operation soapAction="' . $scriptUri . '#testFunc4"/>'
  124. . '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'
  125. . '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'
  126. . '</operation>'
  127. . '</binding>'
  128. . '<service name="Zend_Soap_AutoDiscover_TestService">'
  129. . '<port name="Zend_Soap_AutoDiscover_TestPort" binding="tns:Zend_Soap_AutoDiscover_TestBinding">'
  130. . '<soap:address location="' . $scriptUri . '"/>'
  131. . '</port>'
  132. . '</service>'
  133. . '<message name="testFunc1In"/>'
  134. . '<message name="testFunc1Out"><part name="return" type="xsd:string"/></message>'
  135. . '<message name="testFunc2In"><part name="who" type="xsd:string"/></message>'
  136. . '<message name="testFunc2Out"><part name="return" type="xsd:string"/></message>'
  137. . '<message name="testFunc3In"><part name="who" type="xsd:string"/><part name="when" type="xsd:int"/></message>'
  138. . '<message name="testFunc3Out"><part name="return" type="xsd:string"/></message>'
  139. . '<message name="testFunc4In"/>'
  140. . '<message name="testFunc4Out"><part name="return" type="xsd:string"/></message>'
  141. . '</definitions>';
  142. $dom->save(dirname(__FILE__).'/_files/setclass.wsdl');
  143. $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
  144. $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");
  145. unlink(dirname(__FILE__).'/_files/setclass.wsdl');
  146. }
  147. function testSetClassWithDifferentStyles()
  148. {
  149. $scriptUri = 'http://localhost/my_script.php';
  150. $server = new Zend_Soap_AutoDiscover();
  151. $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com'));
  152. $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com'));
  153. $server->setClass('Zend_Soap_AutoDiscover_Test');
  154. $dom = new DOMDocument();
  155. ob_start();
  156. $server->handle();
  157. $dom->loadXML(ob_get_clean());
  158. $wsdl = '<?xml version="1.0"?>'
  159. . '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
  160. . 'xmlns:tns="' . $scriptUri . '" '
  161. . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
  162. . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
  163. . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
  164. . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
  165. . 'name="Zend_Soap_AutoDiscover_Test" '
  166. . 'targetNamespace="' . $scriptUri . '">'
  167. . '<types>'
  168. . '<xsd:schema targetNamespace="' . $scriptUri . '">'
  169. . '<xsd:element name="testFunc1">'
  170. . '<xsd:complexType/>'
  171. . '</xsd:element>'
  172. . '<xsd:element name="testFunc1Response">'
  173. . '<xsd:complexType>'
  174. . '<xsd:sequence>'
  175. . '<xsd:element name="testFunc1Result" type="xsd:string"/>'
  176. . '</xsd:sequence>'
  177. . '</xsd:complexType>'
  178. . '</xsd:element>'
  179. . '<xsd:element name="testFunc2">'
  180. . '<xsd:complexType>'
  181. . '<xsd:sequence>'
  182. . '<xsd:element name="who" type="xsd:string"/>'
  183. . '</xsd:sequence>'
  184. . '</xsd:complexType>'
  185. . '</xsd:element>'
  186. . '<xsd:element name="testFunc2Response">'
  187. . '<xsd:complexType>'
  188. . '<xsd:sequence>'
  189. . '<xsd:element name="testFunc2Result" type="xsd:string"/>'
  190. . '</xsd:sequence>'
  191. . '</xsd:complexType>'
  192. . '</xsd:element>'
  193. . '<xsd:element name="testFunc3">'
  194. . '<xsd:complexType>'
  195. . '<xsd:sequence>'
  196. . '<xsd:element name="who" type="xsd:string"/>'
  197. . '<xsd:element name="when" type="xsd:int"/>'
  198. . '</xsd:sequence>'
  199. . '</xsd:complexType>'
  200. . '</xsd:element>'
  201. . '<xsd:element name="testFunc3Response">'
  202. . '<xsd:complexType>'
  203. . '<xsd:sequence>'
  204. . '<xsd:element name="testFunc3Result" type="xsd:string"/>'
  205. . '</xsd:sequence>'
  206. . '</xsd:complexType>'
  207. . '</xsd:element>'
  208. . '<xsd:element name="testFunc4">'
  209. . '<xsd:complexType/>'
  210. . '</xsd:element>'
  211. . '<xsd:element name="testFunc4Response">'
  212. . '<xsd:complexType>'
  213. . '<xsd:sequence>'
  214. . '<xsd:element name="testFunc4Result" type="xsd:string"/>'
  215. . '</xsd:sequence>'
  216. . '</xsd:complexType>'
  217. . '</xsd:element>'
  218. . '</xsd:schema>'
  219. . '</types>'
  220. . '<portType name="Zend_Soap_AutoDiscover_TestPort">'
  221. . '<operation name="testFunc1">'
  222. . '<documentation>Test Function 1</documentation>'
  223. . '<input message="tns:testFunc1In"/>'
  224. . '<output message="tns:testFunc1Out"/>'
  225. . '</operation>'
  226. . '<operation name="testFunc2">'
  227. . '<documentation>Test Function 2</documentation>'
  228. . '<input message="tns:testFunc2In"/>'
  229. . '<output message="tns:testFunc2Out"/>'
  230. . '</operation>'
  231. . '<operation name="testFunc3">'
  232. . '<documentation>Test Function 3</documentation>'
  233. . '<input message="tns:testFunc3In"/>'
  234. . '<output message="tns:testFunc3Out"/>'
  235. . '</operation><operation name="testFunc4">'
  236. . '<documentation>Test Function 4</documentation>'
  237. . '<input message="tns:testFunc4In"/>'
  238. . '<output message="tns:testFunc4Out"/>'
  239. . '</operation>'
  240. . '</portType>'
  241. . '<binding name="Zend_Soap_AutoDiscover_TestBinding" type="tns:Zend_Soap_AutoDiscover_TestPort">'
  242. . '<soap:binding style="document" transport="http://framework.zend.com"/>'
  243. . '<operation name="testFunc1">'
  244. . '<soap:operation soapAction="' . $scriptUri . '#testFunc1"/>'
  245. . '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'
  246. . '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'
  247. . '</operation>'
  248. . '<operation name="testFunc2">'
  249. . '<soap:operation soapAction="' . $scriptUri . '#testFunc2"/>'
  250. . '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'
  251. . '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'
  252. . '</operation>'
  253. . '<operation name="testFunc3">'
  254. . '<soap:operation soapAction="' . $scriptUri . '#testFunc3"/>'
  255. . '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'
  256. . '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'
  257. . '</operation>'
  258. . '<operation name="testFunc4">'
  259. . '<soap:operation soapAction="' . $scriptUri . '#testFunc4"/>'
  260. . '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'
  261. . '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'
  262. . '</operation>'
  263. . '</binding>'
  264. . '<service name="Zend_Soap_AutoDiscover_TestService">'
  265. . '<port name="Zend_Soap_AutoDiscover_TestPort" binding="tns:Zend_Soap_AutoDiscover_TestBinding">'
  266. . '<soap:address location="' . $scriptUri . '"/>'
  267. . '</port>'
  268. . '</service>'
  269. . '<message name="testFunc1In">'
  270. . '<part name="parameters" element="tns:testFunc1"/>'
  271. . '</message>'
  272. . '<message name="testFunc1Out">'
  273. . '<part name="parameters" element="tns:testFunc1Response"/>'
  274. . '</message>'
  275. . '<message name="testFunc2In">'
  276. . '<part name="parameters" element="tns:testFunc2"/>'
  277. . '</message>'
  278. . '<message name="testFunc2Out">'
  279. . '<part name="parameters" element="tns:testFunc2Response"/>'
  280. . '</message>'
  281. . '<message name="testFunc3In">'
  282. . '<part name="parameters" element="tns:testFunc3"/>'
  283. . '</message>'
  284. . '<message name="testFunc3Out">'
  285. . '<part name="parameters" element="tns:testFunc3Response"/>'
  286. . '</message>'
  287. . '<message name="testFunc4In">'
  288. . '<part name="parameters" element="tns:testFunc4"/>'
  289. . '</message>'
  290. . '<message name="testFunc4Out">'
  291. . '<part name="parameters" element="tns:testFunc4Response"/>'
  292. . '</message>'
  293. . '</definitions>';
  294. $dom->save(dirname(__FILE__).'/_files/setclass.wsdl');
  295. $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
  296. $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");
  297. unlink(dirname(__FILE__).'/_files/setclass.wsdl');
  298. }
  299. /**
  300. * @group ZF-5072
  301. */
  302. function testSetClassWithResponseReturnPartCompabilityMode()
  303. {
  304. $scriptUri = 'http://localhost/my_script.php';
  305. $server = new Zend_Soap_AutoDiscover();
  306. $server->setClass('Zend_Soap_AutoDiscover_Test');
  307. $dom = new DOMDocument();
  308. ob_start();
  309. $server->handle();
  310. $dom->loadXML(ob_get_clean());
  311. $dom->save(dirname(__FILE__).'/_files/setclass.wsdl');
  312. $this->assertContains('<message name="testFunc1Out"><part name="return"', $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
  313. $this->assertContains('<message name="testFunc2Out"><part name="return"', $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
  314. $this->assertContains('<message name="testFunc3Out"><part name="return"', $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
  315. $this->assertContains('<message name="testFunc4Out"><part name="return"', $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()));
  316. unlink(dirname(__FILE__).'/_files/setclass.wsdl');
  317. }
  318. function testAddFunctionSimple()
  319. {
  320. $scriptUri = 'http://localhost/my_script.php';
  321. $server = new Zend_Soap_AutoDiscover();
  322. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  323. $dom = new DOMDocument();
  324. ob_start();
  325. $server->handle();
  326. $dom->loadXML(ob_get_clean());
  327. $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl');
  328. $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
  329. $name = $parts[0];
  330. $wsdl = '<?xml version="1.0"?>'.
  331. '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="' . $scriptUri . '" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="' .$name. '" targetNamespace="' . $scriptUri . '">'.
  332. '<types><xsd:schema targetNamespace="' . $scriptUri . '"/></types>'.
  333. '<portType name="' .$name. 'Port">'.
  334. '<operation name="Zend_Soap_AutoDiscover_TestFunc"><documentation>Test Function</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFuncIn"/><output message="tns:Zend_Soap_AutoDiscover_TestFuncOut"/></operation>'.
  335. '</portType>'.
  336. '<binding name="' .$name. 'Binding" type="tns:' .$name. 'Port">'.
  337. '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>'.
  338. '<operation name="Zend_Soap_AutoDiscover_TestFunc">'.
  339. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc"/>'.
  340. '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/my_script.php"/></input>'.
  341. '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/my_script.php"/></output>'.
  342. '</operation>'.
  343. '</binding>'.
  344. '<service name="' .$name. 'Service">'.
  345. '<port name="' .$name. 'Port" binding="tns:' .$name. 'Binding">'.
  346. '<soap:address location="' . $scriptUri . '"/>'.
  347. '</port>'.
  348. '</service>'.
  349. '<message name="Zend_Soap_AutoDiscover_TestFuncIn"><part name="who" type="xsd:string"/></message>'.
  350. '<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="return" type="xsd:string"/></message>'.
  351. '</definitions>';
  352. $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated");
  353. $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");
  354. unlink(dirname(__FILE__).'/_files/addfunction.wsdl');
  355. }
  356. function testAddFunctionSimpleWithDifferentStyle()
  357. {
  358. $scriptUri = 'http://localhost/my_script.php';
  359. $server = new Zend_Soap_AutoDiscover();
  360. $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com'));
  361. $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com'));
  362. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  363. $dom = new DOMDocument();
  364. ob_start();
  365. $server->handle();
  366. $dom->loadXML(ob_get_clean());
  367. $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl');
  368. $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
  369. $name = $parts[0];
  370. $wsdl = '<?xml version="1.0"?>'.
  371. '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="' . $scriptUri . '" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="' .$name. '" targetNamespace="' . $scriptUri . '">'.
  372. '<types>'.
  373. '<xsd:schema targetNamespace="' . $scriptUri . '">'.
  374. '<xsd:element name="Zend_Soap_AutoDiscover_TestFunc"><xsd:complexType><xsd:sequence><xsd:element name="who" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element>'.
  375. '<xsd:element name="Zend_Soap_AutoDiscover_TestFuncResponse"><xsd:complexType><xsd:sequence><xsd:element name="Zend_Soap_AutoDiscover_TestFuncResult" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element>'.
  376. '</xsd:schema>'.
  377. '</types>'.
  378. '<portType name="' .$name. 'Port">'.
  379. '<operation name="Zend_Soap_AutoDiscover_TestFunc"><documentation>Test Function</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFuncIn"/><output message="tns:Zend_Soap_AutoDiscover_TestFuncOut"/></operation>'.
  380. '</portType>'.
  381. '<binding name="' .$name. 'Binding" type="tns:' .$name. 'Port">'.
  382. '<soap:binding style="document" transport="http://framework.zend.com"/>'.
  383. '<operation name="Zend_Soap_AutoDiscover_TestFunc">'.
  384. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc"/>'.
  385. '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'.
  386. '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'.
  387. '</operation>'.
  388. '</binding>'.
  389. '<service name="' .$name. 'Service">'.
  390. '<port name="' .$name. 'Port" binding="tns:' .$name. 'Binding">'.
  391. '<soap:address location="' . $scriptUri . '"/>'.
  392. '</port>'.
  393. '</service>'.
  394. '<message name="Zend_Soap_AutoDiscover_TestFuncIn"><part name="parameters" element="tns:Zend_Soap_AutoDiscover_TestFunc"/></message>'.
  395. '<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="parameters" element="tns:Zend_Soap_AutoDiscover_TestFuncResponse"/></message>'.
  396. '</definitions>';
  397. $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated");
  398. $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");
  399. unlink(dirname(__FILE__).'/_files/addfunction.wsdl');
  400. }
  401. /**
  402. * @group ZF-5072
  403. */
  404. function testAddFunctionSimpleInReturnNameCompabilityMode()
  405. {
  406. $scriptUri = 'http://localhost/my_script.php';
  407. $server = new Zend_Soap_AutoDiscover();
  408. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  409. $dom = new DOMDocument();
  410. ob_start();
  411. $server->handle();
  412. $dom->loadXML(ob_get_clean());
  413. $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl');
  414. $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
  415. $name = $parts[0];
  416. $wsdl = $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML());
  417. $this->assertContains('<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="return" type="xsd:string"/>', $wsdl);
  418. $this->assertNotContains('<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="Zend_Soap_AutoDiscover_TestFuncReturn"', $wsdl);
  419. $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");
  420. unlink(dirname(__FILE__).'/_files/addfunction.wsdl');
  421. }
  422. function testAddFunctionMultiple()
  423. {
  424. $scriptUri = 'http://localhost/my_script.php';
  425. $server = new Zend_Soap_AutoDiscover();
  426. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  427. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc2');
  428. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc3');
  429. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc4');
  430. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc5');
  431. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc6');
  432. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc7');
  433. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc9');
  434. $dom = new DOMDocument();
  435. ob_start();
  436. $server->handle();
  437. $dom->loadXML(ob_get_clean());
  438. $dom->save(dirname(__FILE__).'/_files/addfunction2.wsdl');
  439. $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
  440. $name = $parts[0];
  441. $wsdl = '<?xml version="1.0"?>'.
  442. '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="' . $scriptUri . '" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="' .$name. '" targetNamespace="' . $scriptUri . '">'.
  443. '<types><xsd:schema targetNamespace="' . $scriptUri . '"/></types>'.
  444. '<portType name="' .$name. 'Port">'.
  445. '<operation name="Zend_Soap_AutoDiscover_TestFunc"><documentation>Test Function</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFuncIn"/><output message="tns:Zend_Soap_AutoDiscover_TestFuncOut"/></operation>'.
  446. '<operation name="Zend_Soap_AutoDiscover_TestFunc2"><documentation>Test Function 2</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc2In"/></operation>'.
  447. '<operation name="Zend_Soap_AutoDiscover_TestFunc3"><documentation>Return false</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc3In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc3Out"/></operation>'.
  448. '<operation name="Zend_Soap_AutoDiscover_TestFunc4"><documentation>Return true</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc4In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc4Out"/></operation>'.
  449. '<operation name="Zend_Soap_AutoDiscover_TestFunc5"><documentation>Return integer</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc5In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc5Out"/></operation>'.
  450. '<operation name="Zend_Soap_AutoDiscover_TestFunc6"><documentation>Return string</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc6In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc6Out"/></operation>'.
  451. '<operation name="Zend_Soap_AutoDiscover_TestFunc7"><documentation>Return array</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc7In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc7Out"/></operation>'.
  452. '<operation name="Zend_Soap_AutoDiscover_TestFunc9"><documentation>Multiple Args</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFunc9In"/><output message="tns:Zend_Soap_AutoDiscover_TestFunc9Out"/></operation>'.
  453. '</portType>'.
  454. '<binding name="' .$name. 'Binding" type="tns:' .$name. 'Port">'.
  455. '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>'.
  456. '<operation name="Zend_Soap_AutoDiscover_TestFunc">'.
  457. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc"/>'.
  458. '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
  459. '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
  460. '</operation>'.
  461. '<operation name="Zend_Soap_AutoDiscover_TestFunc2">'.
  462. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc2"/>'.
  463. '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
  464. '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
  465. '</operation>'.
  466. '<operation name="Zend_Soap_AutoDiscover_TestFunc3">'.
  467. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc3"/>'.
  468. '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
  469. '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
  470. '</operation>'.
  471. '<operation name="Zend_Soap_AutoDiscover_TestFunc4">'.
  472. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc4"/>'.
  473. '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
  474. '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
  475. '</operation>'.
  476. '<operation name="Zend_Soap_AutoDiscover_TestFunc5">'.
  477. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc5"/>'.
  478. '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
  479. '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
  480. '</operation>'.
  481. '<operation name="Zend_Soap_AutoDiscover_TestFunc6">'.
  482. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc6"/>'.
  483. '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
  484. '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
  485. '</operation>'.
  486. '<operation name="Zend_Soap_AutoDiscover_TestFunc7">'.
  487. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc7"/>'.
  488. '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
  489. '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
  490. '</operation>'.
  491. '<operation name="Zend_Soap_AutoDiscover_TestFunc9">'.
  492. '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_TestFunc9"/>'.
  493. '<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
  494. '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
  495. '</operation>'.
  496. '</binding>'.
  497. '<service name="' .$name. 'Service">'.
  498. '<port name="' .$name. 'Port" binding="tns:' .$name. 'Binding">'.
  499. '<soap:address location="' . $scriptUri . '"/>'.
  500. '</port>'.
  501. '</service>'.
  502. '<message name="Zend_Soap_AutoDiscover_TestFuncIn"><part name="who" type="xsd:string"/></message>'.
  503. '<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="return" type="xsd:string"/></message>'.
  504. '<message name="Zend_Soap_AutoDiscover_TestFunc2In"/>'.
  505. '<message name="Zend_Soap_AutoDiscover_TestFunc3In"/>'.
  506. '<message name="Zend_Soap_AutoDiscover_TestFunc3Out"><part name="return" type="xsd:boolean"/></message>'.
  507. '<message name="Zend_Soap_AutoDiscover_TestFunc4In"/>'.
  508. '<message name="Zend_Soap_AutoDiscover_TestFunc4Out"><part name="return" type="xsd:boolean"/></message>'.
  509. '<message name="Zend_Soap_AutoDiscover_TestFunc5In"/>'.
  510. '<message name="Zend_Soap_AutoDiscover_TestFunc5Out"><part name="return" type="xsd:int"/></message>'.
  511. '<message name="Zend_Soap_AutoDiscover_TestFunc6In"/>'.
  512. '<message name="Zend_Soap_AutoDiscover_TestFunc6Out"><part name="return" type="xsd:string"/></message>'.
  513. '<message name="Zend_Soap_AutoDiscover_TestFunc7In"/>'.
  514. '<message name="Zend_Soap_AutoDiscover_TestFunc7Out"><part name="return" type="soap-enc:Array"/></message>'.
  515. '<message name="Zend_Soap_AutoDiscover_TestFunc9In"><part name="foo" type="xsd:string"/><part name="bar" type="xsd:string"/></message>'.
  516. '<message name="Zend_Soap_AutoDiscover_TestFunc9Out"><part name="return" type="xsd:string"/></message>'.
  517. '</definitions>';
  518. $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML");
  519. $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate");
  520. unlink(dirname(__FILE__).'/_files/addfunction2.wsdl');
  521. }
  522. /**
  523. * @group ZF-4117
  524. */
  525. public function testUseHttpsSchemaIfAccessedThroughHttps()
  526. {
  527. $_SERVER['HTTPS'] = "on";
  528. $httpsScriptUri = 'https://localhost/my_script.php';
  529. $server = new Zend_Soap_AutoDiscover();
  530. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  531. ob_start();
  532. $server->handle();
  533. $wsdlOutput = ob_get_clean();
  534. $this->assertContains($httpsScriptUri, $wsdlOutput);
  535. }
  536. /**
  537. * @group ZF-4117
  538. */
  539. public function testChangeWsdlUriInConstructor()
  540. {
  541. $scriptUri = 'http://localhost/my_script.php';
  542. $server = new Zend_Soap_AutoDiscover(true, "http://example.com/service.php");
  543. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  544. ob_start();
  545. $server->handle();
  546. $wsdlOutput = ob_get_clean();
  547. $this->assertNotContains($scriptUri, $wsdlOutput);
  548. $this->assertContains("http://example.com/service.php", $wsdlOutput);
  549. }
  550. /**
  551. * @group ZF-4117
  552. */
  553. public function testChangeWsdlUriViaSetUri()
  554. {
  555. $scriptUri = 'http://localhost/my_script.php';
  556. $server = new Zend_Soap_AutoDiscover(true);
  557. $server->setUri("http://example.com/service.php");
  558. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  559. ob_start();
  560. $server->handle();
  561. $wsdlOutput = ob_get_clean();
  562. $this->assertNotContains($scriptUri, $wsdlOutput);
  563. $this->assertContains("http://example.com/service.php", $wsdlOutput);
  564. }
  565. public function testSetNonStringNonZendUriUriThrowsException()
  566. {
  567. $server = new Zend_Soap_AutoDiscover();
  568. try {
  569. $server->setUri(array("bogus"));
  570. $this->fail();
  571. } catch(Zend_Soap_AutoDiscover_Exception $e) {
  572. }
  573. }
  574. /**
  575. * @group ZF-4117
  576. */
  577. public function testChangingWsdlUriAfterGenerationIsPossible()
  578. {
  579. $scriptUri = 'http://localhost/my_script.php';
  580. $server = new Zend_Soap_AutoDiscover(true);
  581. $server->setUri("http://example.com/service.php");
  582. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  583. ob_start();
  584. $server->handle();
  585. $wsdlOutput = ob_get_clean();
  586. $this->assertNotContains($scriptUri, $wsdlOutput);
  587. $this->assertContains("http://example.com/service.php", $wsdlOutput);
  588. $server->setUri("http://example2.com/service2.php");
  589. ob_start();
  590. $server->handle();
  591. $wsdlOutput = ob_get_clean();
  592. $this->assertNotContains($scriptUri, $wsdlOutput);
  593. $this->assertNotContains("http://example.com/service.php", $wsdlOutput);
  594. $this->assertContains("http://example2.com/service2.php", $wsdlOutput);
  595. }
  596. /**
  597. * @group ZF-4688
  598. * @group ZF-4125
  599. *
  600. */
  601. public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl()
  602. {
  603. $scriptUri = 'http://localhost/my_script.php';
  604. $server = new Zend_Soap_AutoDiscover();
  605. $server->setClass('Zend_Soap_AutoDiscover_TestFixingMultiplePrototypes');
  606. ob_start();
  607. $server->handle();
  608. $wsdlOutput = ob_get_clean();
  609. $this->assertEquals(1, substr_count($wsdlOutput, '<message name="testFuncIn">'));
  610. $this->assertEquals(1, substr_count($wsdlOutput, '<message name="testFuncOut">'));
  611. }
  612. public function testUnusedFunctionsOfAutoDiscoverThrowException()
  613. {
  614. $server = new Zend_Soap_AutoDiscover();
  615. try {
  616. $server->setPersistence("bogus");
  617. $this->fail();
  618. } catch(Zend_Soap_AutoDiscover_Exception $e) {
  619. }
  620. try {
  621. $server->fault();
  622. $this->fail();
  623. } catch(Zend_Soap_AutoDiscover_Exception $e) {
  624. }
  625. try {
  626. $server->loadFunctions("bogus");
  627. $this->fail();
  628. } catch(Zend_Soap_AutoDiscover_Exception $e) {
  629. }
  630. }
  631. public function testGetFunctions()
  632. {
  633. $server = new Zend_Soap_AutoDiscover();
  634. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  635. $server->setClass('Zend_Soap_AutoDiscover_Test');
  636. $functions = $server->getFunctions();
  637. $this->assertEquals(
  638. array('Zend_Soap_AutoDiscover_TestFunc', 'testFunc1', 'testFunc2', 'testFunc3', 'testFunc4'),
  639. $functions
  640. );
  641. }
  642. /**
  643. * @group ZF-4835
  644. */
  645. public function testUsingRequestUriWithoutParametersAsDefault()
  646. {
  647. // Apache
  648. $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost');
  649. $server = new Zend_Soap_AutoDiscover();
  650. $uri = $server->getUri()->getUri();
  651. $this->assertNotContains("?wsdl", $uri);
  652. $this->assertEquals("http://localhost/my_script.php", $uri);
  653. // Apache plus SSL
  654. $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost', 'HTTPS' => 'on');
  655. $server = new Zend_Soap_AutoDiscover();
  656. $uri = $server->getUri()->getUri();
  657. $this->assertNotContains("?wsdl", $uri);
  658. $this->assertEquals("https://localhost/my_script.php", $uri);
  659. // IIS 5 + PHP as FastCGI
  660. $_SERVER = array('ORIG_PATH_INFO' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost');
  661. $server = new Zend_Soap_AutoDiscover();
  662. $uri = $server->getUri()->getUri();
  663. $this->assertNotContains("?wsdl", $uri);
  664. $this->assertEquals("http://localhost/my_script.php", $uri);
  665. // IIS
  666. $_SERVER = array('HTTP_X_REWRITE_URL' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost');
  667. $server = new Zend_Soap_AutoDiscover();
  668. $uri = $server->getUri()->getUri();
  669. $this->assertNotContains("?wsdl", $uri);
  670. $this->assertEquals("http://localhost/my_script.php", $uri);
  671. }
  672. /**
  673. * @group ZF-4937
  674. */
  675. public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce()
  676. {
  677. $server = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
  678. $server->setClass('Zend_Soap_AutoDiscoverTestClass2');
  679. ob_start();
  680. $server->handle();
  681. $wsdlOutput = ob_get_clean();
  682. $this->assertEquals(1,
  683. substr_count($wsdlOutput, 'wsdl:arrayType="tns:Zend_Soap_AutoDiscoverTestClass1[]"'),
  684. 'wsdl:arrayType definition of TestClass1 has to occour once.'
  685. );
  686. $this->assertEquals(1,
  687. substr_count($wsdlOutput, '<xsd:complexType name="Zend_Soap_AutoDiscoverTestClass1">'),
  688. 'Zend_Soap_AutoDiscoverTestClass1 has to be defined once.'
  689. );
  690. $this->assertEquals(1,
  691. substr_count($wsdlOutput, '<xsd:complexType name="ArrayOfZend_Soap_AutoDiscoverTestClass1">'),
  692. 'ArrayOfZend_Soap_AutoDiscoverTestClass1 should be defined once.'
  693. );
  694. $this->assertTrue(
  695. substr_count($wsdlOutput, '<part name="test" type="tns:Zend_Soap_AutoDiscoverTestClass1"/>') >= 1,
  696. 'Zend_Soap_AutoDiscoverTestClass1 appears once or more than once in the message parts section.'
  697. );
  698. }
  699. /**
  700. * @group ZF-5330
  701. */
  702. public function testDumpOrXmlOfAutoDiscover()
  703. {
  704. $server = new Zend_Soap_AutoDiscover();
  705. $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
  706. ob_start();
  707. $server->handle();
  708. $wsdlOutput = ob_get_clean();
  709. $this->assertEquals(
  710. $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput),
  711. $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml())
  712. );
  713. ob_start();
  714. $server->dump(false);
  715. $wsdlOutput = ob_get_clean();
  716. $this->assertEquals(
  717. $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput),
  718. $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml())
  719. );
  720. }
  721. /**
  722. * @group ZF-5330
  723. */
  724. public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWsdl()
  725. {
  726. $server = new Zend_Soap_AutoDiscover();
  727. try {
  728. $server->dump(false);
  729. $this->fail();
  730. } catch(Exception $e) {
  731. $this->assertTrue($e instanceof Zend_Soap_AutoDiscover_Exception);
  732. }
  733. try {
  734. $server->toXml();
  735. $this->fail();
  736. } catch(Exception $e) {
  737. $this->assertTrue($e instanceof Zend_Soap_AutoDiscover_Exception);
  738. }
  739. }
  740. /**
  741. * @group ZF-5604
  742. */
  743. public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayComplex()
  744. {
  745. $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
  746. $autodiscover->setClass('Zend_Soap_AutoDiscover_MyService');
  747. $wsdl = $autodiscover->toXml();
  748. $this->assertEquals(1, substr_count($wsdl, '<xsd:complexType name="ArrayOfZend_Soap_AutoDiscover_MyResponse">'));
  749. $this->assertEquals(0, substr_count($wsdl, 'tns:My_Response[]'));
  750. }
  751. /**
  752. * @group ZF-5430
  753. */
  754. public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArraySequence()
  755. {
  756. $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
  757. $autodiscover->setClass('Zend_Soap_AutoDiscover_MyServiceSequence');
  758. $wsdl = $autodiscover->toXml();
  759. $this->assertEquals(1, substr_count($wsdl, '<xsd:complexType name="ArrayOfString">'));
  760. $this->assertEquals(1, substr_count($wsdl, '<xsd:complexType name="ArrayOfArrayOfString">'));
  761. $this->assertEquals(1, substr_count($wsdl, '<xsd:complexType name="ArrayOfArrayOfArrayOfString">'));
  762. $this->assertEquals(0, substr_count($wsdl, 'tns:string[]'));
  763. }
  764. /**
  765. * @group ZF-5736
  766. */
  767. public function testAmpersandInUrlIsCorrectlyEncoded()
  768. {
  769. $autodiscover = new Zend_Soap_AutoDiscover();
  770. $autodiscover->setUri("http://example.com/?a=b&amp;b=c");
  771. $autodiscover->setClass("Zend_Soap_AutoDiscover_Test");
  772. $wsdl = $autodiscover->toXml();
  773. $this->assertContains("http://example.com/?a=b&amp;b=c", $wsdl);
  774. }
  775. /**
  776. * @group ZF-6689
  777. */
  778. public function testNoReturnIsOneWayCallInSetClass()
  779. {
  780. $autodiscover = new Zend_Soap_AutoDiscover();
  781. $autodiscover->setClass('Zend_Soap_AutoDiscover_NoReturnType');
  782. $wsdl = $autodiscover->toXml();
  783. $this->assertContains(
  784. '<operation name="pushOneWay"><documentation>@param string $message</documentation><input message="tns:pushOneWayIn"/></operation>',
  785. $wsdl
  786. );
  787. }
  788. /**
  789. * @group ZF-6689
  790. */
  791. public function testNoReturnIsOneWayCallInAddFunction()
  792. {
  793. $autodiscover = new Zend_Soap_AutoDiscover();
  794. $autodiscover->addFunction('Zend_Soap_AutoDiscover_OneWay');
  795. $wsdl = $autodiscover->toXml();
  796. $this->assertContains(
  797. '<operation name="Zend_Soap_AutoDiscover_OneWay"><documentation>@param string $message</documentation><input message="tns:Zend_Soap_AutoDiscover_OneWayIn"/></operation>',
  798. $wsdl
  799. );
  800. }
  801. }