PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/Zend/Soap/TestAsset/commontypes.php

https://bitbucket.org/dbaltas/zend-framework-1.x-on-git
PHP | 634 lines | 465 code | 27 blank | 142 comment | 0 complexity | 6ff5a5638a66f26e83642081700373b9 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT
  1. <?php
  2. /**
  3. * Zend Framework (http://framework.zend.com/)
  4. *
  5. * @link http://github.com/zendframework/zf2 for the canonical source repository
  6. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  7. * @license http://framework.zend.com/license/new-bsd New BSD License
  8. * @package Zend_Soap
  9. */
  10. /* Test Functions */
  11. /**
  12. * Test Function
  13. *
  14. * @param string $arg
  15. * @return string
  16. */
  17. function Zend_Soap_TestAsset_TestFunc($who)
  18. {
  19. return "Hello $who";
  20. }
  21. /**
  22. * Test Function 2
  23. */
  24. function Zend_Soap_TestAsset_TestFunc2()
  25. {
  26. return "Hello World";
  27. }
  28. /**
  29. * Return false
  30. *
  31. * @return bool
  32. */
  33. function Zend_Soap_TestAsset_TestFunc3()
  34. {
  35. return false;
  36. }
  37. /**
  38. * Return true
  39. *
  40. * @return bool
  41. */
  42. function Zend_Soap_TestAsset_TestFunc4()
  43. {
  44. return true;
  45. }
  46. /**
  47. * Return integer
  48. *
  49. * @return int
  50. */
  51. function Zend_Soap_TestAsset_TestFunc5()
  52. {
  53. return 123;
  54. }
  55. /**
  56. * Return string
  57. *
  58. * @return string
  59. */
  60. function Zend_Soap_TestAsset_TestFunc6()
  61. {
  62. return "string";
  63. }
  64. /**
  65. * Return array
  66. *
  67. * @return array
  68. */
  69. function Zend_Soap_TestAsset_TestFunc7()
  70. {
  71. return array('foo' => 'bar', 'baz' => true, 1 => false, 'bat' => 123);
  72. }
  73. /**
  74. * Return Object
  75. *
  76. * @return StdClass
  77. */
  78. function Zend_Soap_TestAsset_TestFunc8()
  79. {
  80. $return = (object) array('foo' => 'bar', 'baz' => true, 'bat' => 123, 'qux' => false);
  81. return $return;
  82. }
  83. /**
  84. * Multiple Args
  85. *
  86. * @param string $foo
  87. * @param string $bar
  88. * @return string
  89. */
  90. function Zend_Soap_TestAsset_TestFunc9($foo, $bar)
  91. {
  92. return "$foo $bar";
  93. }
  94. /**
  95. * @category Zend
  96. * @package Zend_Soap
  97. * @subpackage UnitTests
  98. */
  99. class Zend_Soap_TestAsset_TestFixingMultiplePrototypes
  100. {
  101. /**
  102. * Test function
  103. *
  104. * @param integer $a
  105. * @param integer $b
  106. * @param integer $d
  107. * @return integer
  108. */
  109. public function testFunc($a=100, $b=200, $d=300)
  110. {
  111. }
  112. }
  113. /**
  114. * @category Zend
  115. * @package Zend_Soap
  116. * @subpackage UnitTests
  117. */
  118. class Zend_Soap_TestAsset_Test
  119. {
  120. /**
  121. * Test Function 1
  122. *
  123. * @return string
  124. */
  125. public function testFunc1()
  126. {
  127. return "Hello World";
  128. }
  129. /**
  130. * Test Function 2
  131. *
  132. * @param string $who Some Arg
  133. * @return string
  134. */
  135. public function testFunc2($who)
  136. {
  137. return "Hello $who!";
  138. }
  139. /**
  140. * Test Function 3
  141. *
  142. * @param string $who Some Arg
  143. * @param int $when Some
  144. * @return string
  145. */
  146. public function testFunc3($who, $when)
  147. {
  148. return "Hello $who, How are you $when";
  149. }
  150. /**
  151. * Test Function 4
  152. *
  153. * @return string
  154. */
  155. public static function testFunc4()
  156. {
  157. return "I'm Static!";
  158. }
  159. }
  160. class Zend_Soap_TestAsset_AutoDiscoverTestClass1
  161. {
  162. /**
  163. * @var integer $var
  164. */
  165. public $var = 1;
  166. /**
  167. * @var string $param
  168. */
  169. public $param = "hello";
  170. }
  171. /**
  172. * @category Zend
  173. * @package Zend_Soap
  174. * @subpackage UnitTests
  175. */
  176. class Zend_Soap_TestAsset_AutoDiscoverTestClass2
  177. {
  178. /**
  179. *
  180. * @param Zend_Soap_TestAsset_AutoDiscoverTestClass1 $test
  181. * @return boolean
  182. */
  183. public function add(AutoDiscoverTestClass1 $test)
  184. {
  185. return true;
  186. }
  187. /**
  188. * @return Zend_Soap_TestAsset_AutoDiscoverTestClass1[]
  189. */
  190. public function fetchAll()
  191. {
  192. return array(
  193. new AutoDiscoverTestClass1(),
  194. new AutoDiscoverTestClass1(),
  195. );
  196. }
  197. /**
  198. * @param Zend_Soap_TestAsset_AutoDiscoverTestClass1[]
  199. */
  200. public function addMultiple($test)
  201. {
  202. }
  203. }
  204. /**
  205. * @category Zend
  206. * @package Zend_Soap
  207. * @subpackage UnitTests
  208. */
  209. class Zend_Soap_TestAsset_ComplexTypeB
  210. {
  211. /**
  212. * @var string
  213. */
  214. public $bar;
  215. /**
  216. * @var string
  217. */
  218. public $foo;
  219. }
  220. /**
  221. * @category Zend
  222. * @package Zend_Soap
  223. * @subpackage UnitTests
  224. */
  225. class Zend_Soap_TestAsset_ComplexTypeA
  226. {
  227. /**
  228. * @var Zend_Soap_TestAsset_ComplexTypeB[]
  229. */
  230. public $baz = array();
  231. }
  232. /**
  233. * @category Zend
  234. * @package Zend_Soap
  235. * @subpackage UnitTests
  236. */
  237. class Zend_Soap_TestAsset_ComplexTest
  238. {
  239. /**
  240. * @var int
  241. */
  242. public $var = 5;
  243. }
  244. /**
  245. * @category Zend
  246. * @package Zend_Soap
  247. * @subpackage UnitTests
  248. */
  249. class Zend_Soap_TestAsset_ComplexObjectStructure
  250. {
  251. /**
  252. * @var boolean
  253. */
  254. public $boolean = true;
  255. /**
  256. * @var string
  257. */
  258. public $string = "Hello World";
  259. /**
  260. * @var int
  261. */
  262. public $int = 10;
  263. /**
  264. * @var array
  265. */
  266. public $array = array(1, 2, 3);
  267. }
  268. /**
  269. * @category Zend
  270. * @package Zend_Soap
  271. * @subpackage UnitTests
  272. */
  273. class Zend_Soap_TestAsset_ComplexObjectWithObjectStructure
  274. {
  275. /**
  276. * @var Zend_Soap_TestAsset_ComplexTest
  277. */
  278. public $object;
  279. }
  280. /**
  281. * @category Zend
  282. * @package Zend_Soap
  283. * @subpackage UnitTests
  284. */
  285. class Zend_Soap_TestAsset_MyService
  286. {
  287. /**
  288. * @param string $foo
  289. * @return Zend_Soap_TestAsset_MyResponse[]
  290. */
  291. public function foo($foo)
  292. {
  293. }
  294. /**
  295. * @param string $bar
  296. * @return Zend_Soap_TestAsset_MyResponse[]
  297. */
  298. public function bar($bar)
  299. {
  300. }
  301. /**
  302. * @param string $baz
  303. * @return Zend_Soap_TestAsset_MyResponse[]
  304. */
  305. public function baz($baz)
  306. {
  307. }
  308. }
  309. /**
  310. * @category Zend
  311. * @package Zend_Soap
  312. * @subpackage UnitTests
  313. */
  314. class Zend_Soap_TestAsset_MyServiceSequence
  315. {
  316. /**
  317. * @param string $foo
  318. * @return string[]
  319. */
  320. public function foo($foo)
  321. {
  322. }
  323. /**
  324. * @param string $bar
  325. * @return string[]
  326. */
  327. public function bar($bar)
  328. {
  329. }
  330. /**
  331. * @param string $baz
  332. * @return string[]
  333. */
  334. public function baz($baz)
  335. {
  336. }
  337. /**
  338. * @param string $baz
  339. * @return string[][][]
  340. */
  341. public function bazNested($baz)
  342. {
  343. }
  344. }
  345. /**
  346. * @category Zend
  347. * @package Zend_Soap
  348. * @subpackage UnitTests
  349. */
  350. class Zend_Soap_TestAsset_MyResponse
  351. {
  352. /**
  353. * @var string
  354. */
  355. public $p1;
  356. }
  357. /**
  358. * @category Zend
  359. * @package Zend_Soap
  360. * @subpackage UnitTests
  361. */
  362. class Zend_Soap_TestAsset_Recursion
  363. {
  364. /**
  365. * @var Zend_Soap_TestAsset_Recursion
  366. */
  367. public $recursion;
  368. /**
  369. * @return Zend_Soap_TestAsset_Recursion
  370. */
  371. public function create() {}
  372. }
  373. /**
  374. * @param string $message
  375. */
  376. function Zend_Soap_TestAsset_OneWay($message)
  377. {
  378. }
  379. /**
  380. * @category Zend
  381. * @package Zend_Soap
  382. * @subpackage UnitTests
  383. */
  384. class Zend_Soap_TestAsset_NoReturnType
  385. {
  386. /**
  387. *
  388. * @param string $message
  389. */
  390. public function pushOneWay($message)
  391. {
  392. }
  393. }
  394. /* Client test classes */
  395. /** Test Class */
  396. class Zend_Soap_TestAsset_TestClass
  397. {
  398. /**
  399. * Test Function 1
  400. *
  401. * @return string
  402. */
  403. public function testFunc1()
  404. {
  405. return "Hello World";
  406. }
  407. /**
  408. * Test Function 2
  409. *
  410. * @param string $who Some Arg
  411. * @return string
  412. */
  413. public function testFunc2($who)
  414. {
  415. return "Hello $who!";
  416. }
  417. /**
  418. * Test Function 3
  419. *
  420. * @param string $who Some Arg
  421. * @param int $when Some
  422. * @return string
  423. */
  424. public function testFunc3($who, $when)
  425. {
  426. return "Hello $who, How are you $when";
  427. }
  428. /**
  429. * Test Function 4
  430. *
  431. * @return string
  432. */
  433. public static function testFunc4()
  434. {
  435. return "I'm Static!";
  436. }
  437. }
  438. /** Test class 2 */
  439. class Zend_Soap_TestAsset_TestData1
  440. {
  441. /**
  442. * Property1
  443. *
  444. * @var string
  445. */
  446. public $property1;
  447. /**
  448. * Property2
  449. *
  450. * @var float
  451. */
  452. public $property2;
  453. }
  454. /** Test class 2 */
  455. class Zend_Soap_TestAsset_TestData2
  456. {
  457. /**
  458. * Property1
  459. *
  460. * @var integer
  461. */
  462. public $property1;
  463. /**
  464. * Property1
  465. *
  466. * @var float
  467. */
  468. public $property2;
  469. }
  470. class Zend_Soap_TestAsset_MockSoapServer
  471. {
  472. public $handle = null;
  473. public function handle()
  474. {
  475. $this->handle = func_get_args();
  476. }
  477. public function __call($name, $args) {}
  478. }
  479. class Zend_Soap_TestAsset_MockServer extends Zend_Soap_Server
  480. {
  481. public $mockSoapServer = null;
  482. protected function _getSoap()
  483. {
  484. $this->mockSoapServer = new MockSoapServer();
  485. return $this->mockSoapServer;
  486. }
  487. }
  488. /** Server test classes */
  489. class Zend_Soap_TestAsset_ServerTestClass
  490. {
  491. /**
  492. * Test Function 1
  493. *
  494. * @return string
  495. */
  496. public function testFunc1()
  497. {
  498. return "Hello World";
  499. }
  500. /**
  501. * Test Function 2
  502. *
  503. * @param string $who Some Arg
  504. * @return string
  505. */
  506. public function testFunc2($who)
  507. {
  508. return "Hello $who!";
  509. }
  510. /**
  511. * Test Function 3
  512. *
  513. * @param string $who Some Arg
  514. * @param int $when Some
  515. * @return string
  516. */
  517. public function testFunc3($who, $when)
  518. {
  519. return "Hello $who, How are you $when";
  520. }
  521. /**
  522. * Test Function 4
  523. *
  524. * @return string
  525. */
  526. public static function testFunc4()
  527. {
  528. return "I'm Static!";
  529. }
  530. /**
  531. * Test Function 5 raises a user error
  532. *
  533. * @return void
  534. */
  535. public function testFunc5()
  536. {
  537. trigger_error("Test Message", E_USER_ERROR);
  538. }
  539. }
  540. if (extension_loaded('soap')) {
  541. /** Local SOAP client */
  542. class Zend_Soap_TestAsset_TestLocalSoapClient extends SoapClient
  543. {
  544. /**
  545. * Server object
  546. *
  547. * @var Zend_Soap_Server
  548. */
  549. public $server;
  550. /**
  551. * Local client constructor
  552. *
  553. * @param Zend_Soap_Server $server
  554. * @param string $wsdl
  555. * @param array $options
  556. */
  557. public function __construct(Zend_Soap_Server $server, $wsdl, $options)
  558. {
  559. $this->server = $server;
  560. parent::__construct($wsdl, $options);
  561. }
  562. public function __doRequest($request, $location, $action, $version, $one_way = 0)
  563. {
  564. ob_start();
  565. $this->server->handle($request);
  566. $response = ob_get_clean();
  567. return $response;
  568. }
  569. }
  570. }