PageRenderTime 41ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

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

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