ServerTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  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_XmlRpc
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 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. // Call Zend_XmlRpc_ServerTest::main() if this source file is executed directly.
  23. if (!defined('PHPUnit_MAIN_METHOD')) {
  24. define('PHPUnit_MAIN_METHOD', 'Zend_XmlRpc_ServerTest::main');
  25. }
  26. require_once dirname(__FILE__) . '/../../TestHelper.php';
  27. require_once 'Zend/XmlRpc/Server.php';
  28. require_once 'Zend/XmlRpc/Request.php';
  29. require_once 'Zend/XmlRpc/Response.php';
  30. /**
  31. * Test case for Zend_XmlRpc_Server
  32. *
  33. * @category Zend
  34. * @package Zend_XmlRpc
  35. * @subpackage UnitTests
  36. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. * @group Zend_XmlRpc
  39. */
  40. class Zend_XmlRpc_ServerTest extends PHPUnit_Framework_TestCase
  41. {
  42. /**
  43. * Zend_XmlRpc_Server object
  44. * @var Zend_XmlRpc_Server
  45. */
  46. protected $_server;
  47. /**
  48. * Runs the test methods of this class.
  49. *
  50. * @return void
  51. */
  52. public static function main()
  53. {
  54. $suite = new PHPUnit_Framework_TestSuite("Zend_XmlRpc_ServerTest");
  55. $result = PHPUnit_TextUI_TestRunner::run($suite);
  56. }
  57. /**
  58. * Setup environment
  59. */
  60. public function setUp()
  61. {
  62. $this->_server = new Zend_XmlRpc_Server();
  63. }
  64. /**
  65. * Teardown environment
  66. */
  67. public function tearDown()
  68. {
  69. unset($this->_server);
  70. }
  71. /**
  72. * __construct() test
  73. *
  74. * Call as method call
  75. *
  76. * Returns: void
  77. */
  78. public function test__construct()
  79. {
  80. $this->assertTrue($this->_server instanceof Zend_XmlRpc_Server);
  81. }
  82. /**
  83. * addFunction() test
  84. *
  85. * Call as method call
  86. *
  87. * Expects:
  88. * - function:
  89. * - namespace: Optional; has default;
  90. *
  91. * Returns: void
  92. */
  93. public function testAddFunction()
  94. {
  95. try {
  96. $this->_server->addFunction('Zend_XmlRpc_Server_testFunction', 'zsr');
  97. } catch (Zend_XmlRpc_Exception $e) {
  98. $this->fail('Attachment should have worked');
  99. }
  100. $methods = $this->_server->listMethods();
  101. $this->assertTrue(in_array('zsr.Zend_XmlRpc_Server_testFunction', $methods));
  102. try {
  103. $this->_server->addFunction('nosuchfunction');
  104. $this->fail('nosuchfunction() should not exist and should throw an exception');
  105. } catch (Zend_XmlRpc_Exception $e) {
  106. // do nothing
  107. }
  108. $server = new Zend_XmlRpc_Server();
  109. try {
  110. $server->addFunction(
  111. array(
  112. 'Zend_XmlRpc_Server_testFunction',
  113. 'Zend_XmlRpc_Server_testFunction2',
  114. ),
  115. 'zsr'
  116. );
  117. } catch (Zend_XmlRpc_Exception $e) {
  118. $this->fail('Error attaching array of functions: ' . $e->getMessage());
  119. }
  120. $methods = $server->listMethods();
  121. $this->assertTrue(in_array('zsr.Zend_XmlRpc_Server_testFunction', $methods));
  122. $this->assertTrue(in_array('zsr.Zend_XmlRpc_Server_testFunction2', $methods));
  123. }
  124. /**
  125. * get/loadFunctions() test
  126. */
  127. public function testFunctions()
  128. {
  129. try {
  130. $this->_server->addFunction(
  131. array(
  132. 'Zend_XmlRpc_Server_testFunction',
  133. 'Zend_XmlRpc_Server_testFunction2',
  134. ),
  135. 'zsr'
  136. );
  137. } catch (Zend_XmlRpc_Exception $e) {
  138. $this->fail('Error attaching functions: ' . $e->getMessage());
  139. }
  140. $expected = $this->_server->listMethods();
  141. $functions = $this->_server->getFunctions();
  142. $server = new Zend_XmlRpc_Server();
  143. $server->loadFunctions($functions);
  144. $actual = $server->listMethods();
  145. $this->assertSame($expected, $actual);
  146. }
  147. /**
  148. * setClass() test
  149. */
  150. public function testSetClass()
  151. {
  152. $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test');
  153. $methods = $this->_server->listMethods();
  154. $this->assertTrue(in_array('test.test1', $methods));
  155. $this->assertTrue(in_array('test.test2', $methods));
  156. $this->assertFalse(in_array('test._test3', $methods));
  157. $this->assertFalse(in_array('test.__construct', $methods));
  158. }
  159. /**
  160. * @group ZF-6526
  161. */
  162. public function testSettingClassWithArguments()
  163. {
  164. $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test', 'argv-argument');
  165. $request = new Zend_XmlRpc_Request();
  166. $request->setMethod('test.test4');
  167. $response = $this->_server->handle($request);
  168. $this->assertNotType('Zend_XmlRpc_Fault', $response);
  169. $this->assertSame(
  170. array('test1' => 'argv-argument',
  171. 'test2' => null,
  172. 'arg' => array('argv-argument')),
  173. $response->getReturnValue());
  174. }
  175. /**
  176. * fault() test
  177. */
  178. public function testFault()
  179. {
  180. $fault = $this->_server->fault('This is a fault', 411);
  181. $this->assertTrue($fault instanceof Zend_XmlRpc_Server_Fault);
  182. $this->assertEquals(411, $fault->getCode());
  183. $this->assertEquals('This is a fault', $fault->getMessage());
  184. $fault = $this->_server->fault(new Zend_XmlRpc_Server_Exception('Exception fault', 511));
  185. $this->assertTrue($fault instanceof Zend_XmlRpc_Server_Fault);
  186. $this->assertEquals(511, $fault->getCode());
  187. $this->assertEquals('Exception fault', $fault->getMessage());
  188. }
  189. /**
  190. * handle() test
  191. *
  192. * Call as method call
  193. *
  194. * Expects:
  195. * - request: Optional;
  196. *
  197. * Returns: Zend_XmlRpc_Response|Zend_XmlRpc_Fault
  198. */
  199. public function testHandle()
  200. {
  201. $request = new Zend_XmlRpc_Request();
  202. $request->setMethod('system.listMethods');
  203. $response = $this->_server->handle($request);
  204. $this->assertTrue($response instanceof Zend_XmlRpc_Response);
  205. $return = $response->getReturnValue();
  206. $this->assertTrue(is_array($return));
  207. $this->assertTrue(in_array('system.multicall', $return));
  208. }
  209. /**
  210. * Test that only calling methods using a valid parameter signature works
  211. */
  212. public function testHandle2()
  213. {
  214. $request = new Zend_XmlRpc_Request();
  215. $request->setMethod('system.methodHelp');
  216. $response = $this->_server->handle($request);
  217. $this->assertTrue($response instanceof Zend_XmlRpc_Fault);
  218. $this->assertEquals(623, $response->getCode());
  219. }
  220. public function testCallingInvalidMethod()
  221. {
  222. $request = new Zend_XmlRpc_Request();
  223. $request->setMethod('invalid');
  224. $response = $this->_server->handle($request);
  225. $this->assertType('Zend_XmlRpc_Fault', $response);
  226. $this->assertSame('Method "invalid" does not exist', $response->getMessage());
  227. $this->assertSame(620, $response->getCode());
  228. }
  229. /**
  230. * setResponseClass() test
  231. *
  232. * Call as method call
  233. *
  234. * Expects:
  235. * - class:
  236. *
  237. * Returns: boolean
  238. */
  239. public function testSetResponseClass()
  240. {
  241. $this->assertTrue($this->_server->setResponseClass('Zend_XmlRpc_Server_testResponse'));
  242. $request = new Zend_XmlRpc_Request();
  243. $request->setMethod('system.listMethods');
  244. $response = $this->_server->handle($request);
  245. $this->assertTrue($response instanceof Zend_XmlRpc_Response);
  246. $this->assertTrue($response instanceof Zend_XmlRpc_Server_testResponse);
  247. }
  248. /**
  249. * listMethods() test
  250. *
  251. * Call as method call
  252. *
  253. * Returns: array
  254. */
  255. public function testListMethods()
  256. {
  257. $methods = $this->_server->listMethods();
  258. $this->assertTrue(is_array($methods));
  259. $this->assertTrue(in_array('system.listMethods', $methods));
  260. $this->assertTrue(in_array('system.methodHelp', $methods));
  261. $this->assertTrue(in_array('system.methodSignature', $methods));
  262. $this->assertTrue(in_array('system.multicall', $methods));
  263. }
  264. /**
  265. * methodHelp() test
  266. *
  267. * Call as method call
  268. *
  269. * Expects:
  270. * - method:
  271. *
  272. * Returns: string
  273. */
  274. public function testMethodHelp()
  275. {
  276. $help = $this->_server->methodHelp('system.methodHelp', 'system.listMethods');
  277. $this->assertContains('Display help message for an XMLRPC method', $help);
  278. $this->setExpectedException('Zend_XmlRpc_Server_Exception', 'Method "foo" does not exist');
  279. $this->_server->methodHelp('foo');
  280. }
  281. /**
  282. * methodSignature() test
  283. *
  284. * Call as method call
  285. *
  286. * Expects:
  287. * - method:
  288. *
  289. * Returns: array
  290. */
  291. public function testMethodSignature()
  292. {
  293. $sig = $this->_server->methodSignature('system.methodSignature');
  294. $this->assertTrue(is_array($sig));
  295. $this->assertEquals(1, count($sig), var_export($sig, 1));
  296. $this->setExpectedException('Zend_XmlRpc_Server_Exception', 'Method "foo" does not exist');
  297. $this->_server->methodSignature('foo');
  298. }
  299. /**
  300. * multicall() test
  301. *
  302. * Call as method call
  303. *
  304. * Expects:
  305. * - methods:
  306. *
  307. * Returns: array
  308. */
  309. public function testMulticall()
  310. {
  311. $struct = array(
  312. array(
  313. 'methodName' => 'system.listMethods',
  314. 'params' => array()
  315. ),
  316. array(
  317. 'methodName' => 'system.methodHelp',
  318. 'params' => array('system.multicall')
  319. )
  320. );
  321. $request = new Zend_XmlRpc_Request();
  322. $request->setMethod('system.multicall');
  323. $request->addParam($struct);
  324. $response = $this->_server->handle($request);
  325. $this->assertTrue($response instanceof Zend_XmlRpc_Response, $response->__toString() . "\n\n" . $request->__toString());
  326. $returns = $response->getReturnValue();
  327. $this->assertTrue(is_array($returns));
  328. $this->assertEquals(2, count($returns), var_export($returns, 1));
  329. $this->assertTrue(is_array($returns[0]), var_export($returns[0], 1));
  330. $this->assertTrue(is_string($returns[1]), var_export($returns[1], 1));
  331. }
  332. /**
  333. * Test get/setEncoding()
  334. */
  335. public function testGetSetEncoding()
  336. {
  337. $this->assertEquals('UTF-8', $this->_server->getEncoding());
  338. $this->_server->setEncoding('ISO-8859-1');
  339. $this->assertEquals('ISO-8859-1', $this->_server->getEncoding());
  340. }
  341. /**
  342. * Test request/response encoding
  343. */
  344. public function testRequestResponseEncoding()
  345. {
  346. $response = $this->_server->handle();
  347. $request = $this->_server->getRequest();
  348. $this->assertEquals('UTF-8', $request->getEncoding());
  349. $this->assertEquals('UTF-8', $response->getEncoding());
  350. }
  351. /**
  352. * Test request/response encoding (alternate encoding)
  353. */
  354. public function testRequestResponseEncoding2()
  355. {
  356. $this->_server->setEncoding('ISO-8859-1');
  357. $response = $this->_server->handle();
  358. $request = $this->_server->getRequest();
  359. $this->assertEquals('ISO-8859-1', $request->getEncoding());
  360. $this->assertEquals('ISO-8859-1', $response->getEncoding());
  361. }
  362. public function testAddFunctionWithExtraArgs()
  363. {
  364. $this->_server->addFunction('Zend_XmlRpc_Server_testFunction', 'test', 'arg1');
  365. $methods = $this->_server->listMethods();
  366. $this->assertContains('test.Zend_XmlRpc_Server_testFunction', $methods);
  367. }
  368. public function testAddFunctionThrowsExceptionWithBadData()
  369. {
  370. $o = new stdClass();
  371. try {
  372. $this->_server->addFunction($o);
  373. $this->fail('addFunction() should not accept objects');
  374. } catch (Zend_XmlRpc_Exception $e) {
  375. // success
  376. }
  377. }
  378. public function testLoadFunctionsThrowsExceptionWithBadData()
  379. {
  380. $o = new stdClass();
  381. try {
  382. $this->_server->loadFunctions($o);
  383. $this->fail('loadFunctions() should not accept objects');
  384. } catch (Zend_XmlRpc_Exception $e) {
  385. // success
  386. }
  387. try {
  388. $this->_server->loadFunctions('foo');
  389. $this->fail('loadFunctions() should not accept primitive values');
  390. } catch (Zend_XmlRpc_Server_Exception $e) {
  391. // success
  392. }
  393. $o = array($o);
  394. try {
  395. $this->_server->loadFunctions($o);
  396. $this->fail('loadFunctions() should not allow non-reflection objects in an array');
  397. } catch (Zend_Server_Exception $e) {
  398. $this->assertSame('Invalid method provided', $e->getMessage());
  399. }
  400. }
  401. public function testLoadFunctionsReadsMethodsFromServerDefinitionObjects()
  402. {
  403. $mockedMethod = $this->getMock('Zend_Server_Method_Definition', array(), array(), '', false,
  404. false);
  405. $mockedDefinition = $this->getMock('Zend_Server_Definition', array(), array(), '', false, false);
  406. $mockedDefinition->expects($this->once())
  407. ->method('getMethods')
  408. ->will($this->returnValue(array('bar' => $mockedMethod)));
  409. $this->_server->loadFunctions($mockedDefinition);
  410. }
  411. public function testSetClassThrowsExceptionWithInvalidClass()
  412. {
  413. try {
  414. $this->_server->setClass('mybogusclass');
  415. $this->fail('setClass() should not allow invalid classes');
  416. } catch (Zend_XmlRpc_Exception $e) {
  417. }
  418. }
  419. public function testSetRequestUsingString()
  420. {
  421. $this->_server->setRequest('Zend_XmlRpc_Server_testRequest');
  422. $req = $this->_server->getRequest();
  423. $this->assertTrue($req instanceof Zend_XmlRpc_Server_testRequest);
  424. }
  425. public function testSetRequestThrowsExceptionOnBadClass()
  426. {
  427. try {
  428. $this->_server->setRequest('Zend_XmlRpc_Server_testRequest2');
  429. $this->fail('Invalid request class should throw exception');
  430. } catch (Zend_XmlRpc_Exception $e) {
  431. // success
  432. }
  433. try {
  434. $this->_server->setRequest($this);
  435. $this->fail('Invalid request object should throw exception');
  436. } catch (Zend_XmlRpc_Exception $e) {
  437. // success
  438. }
  439. }
  440. public function testHandleObjectMethod()
  441. {
  442. $this->_server->setClass('Zend_XmlRpc_Server_testClass');
  443. $request = new Zend_XmlRpc_Request();
  444. $request->setMethod('test1');
  445. $request->addParam('value');
  446. $response = $this->_server->handle($request);
  447. $this->assertFalse($response instanceof Zend_XmlRpc_Fault);
  448. $this->assertEquals('String: value', $response->getReturnValue());
  449. }
  450. public function testHandleClassStaticMethod()
  451. {
  452. $this->_server->setClass('Zend_XmlRpc_Server_testClass');
  453. $request = new Zend_XmlRpc_Request();
  454. $request->setMethod('test2');
  455. $request->addParam(array('value1', 'value2'));
  456. $response = $this->_server->handle($request);
  457. $this->assertFalse($response instanceof Zend_XmlRpc_Fault);
  458. $this->assertEquals('value1; value2', $response->getReturnValue());
  459. }
  460. public function testHandleFunction()
  461. {
  462. $this->_server->addFunction('Zend_XmlRpc_Server_testFunction');
  463. $request = new Zend_XmlRpc_Request();
  464. $request->setMethod('Zend_XmlRpc_Server_testFunction');
  465. $request->setParams(array(array('value1'), 'key'));
  466. $response = $this->_server->handle($request);
  467. $this->assertFalse($response instanceof Zend_XmlRpc_Fault);
  468. $this->assertEquals('key: value1', $response->getReturnValue());
  469. }
  470. public function testMulticallReturnsFaultsWithBadData()
  471. {
  472. // bad method array
  473. $try = array(
  474. 'system.listMethods',
  475. array(
  476. 'name' => 'system.listMethods'
  477. ),
  478. array(
  479. 'methodName' => 'system.listMethods'
  480. ),
  481. array(
  482. 'methodName' => 'system.listMethods',
  483. 'params' => ''
  484. ),
  485. array(
  486. 'methodName' => 'system.multicall',
  487. 'params' => array()
  488. )
  489. );
  490. $returned = $this->_server->multicall($try);
  491. $this->assertTrue(is_array($returned));
  492. $this->assertEquals(5, count($returned));
  493. $response = $returned[0];
  494. $this->assertTrue(is_array($response));
  495. $this->assertTrue(isset($response['faultCode']));
  496. $this->assertEquals(601, $response['faultCode']);
  497. $response = $returned[1];
  498. $this->assertTrue(is_array($response));
  499. $this->assertTrue(isset($response['faultCode']));
  500. $this->assertEquals(602, $response['faultCode']);
  501. $response = $returned[2];
  502. $this->assertTrue(is_array($response));
  503. $this->assertTrue(isset($response['faultCode']));
  504. $this->assertEquals(603, $response['faultCode']);
  505. $response = $returned[3];
  506. $this->assertTrue(is_array($response));
  507. $this->assertTrue(isset($response['faultCode']));
  508. $this->assertEquals(604, $response['faultCode']);
  509. $response = $returned[4];
  510. $this->assertTrue(is_array($response));
  511. $this->assertTrue(isset($response['faultCode']));
  512. $this->assertEquals(605, $response['faultCode']);
  513. }
  514. /**
  515. * @see ZF-2872
  516. */
  517. public function testCanMarshalBase64Requests()
  518. {
  519. $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test');
  520. $data = base64_encode('this is the payload');
  521. $param = array('type' => 'base64', 'value' => $data);
  522. $request = new Zend_XmlRpc_Request('test.base64', array($param));
  523. $response = $this->_server->handle($request);
  524. $this->assertFalse($response instanceof Zend_XmlRpc_Fault);
  525. $this->assertEquals($data, $response->getReturnValue());
  526. }
  527. /**
  528. * @group ZF-6034
  529. */
  530. public function testPrototypeReturnValueMustReflectDocBlock()
  531. {
  532. $server = new Zend_XmlRpc_Server();
  533. $server->setClass('Zend_XmlRpc_Server_testClass');
  534. $table = $server->getDispatchTable();
  535. $method = $table->getMethod('test1');
  536. foreach ($method->getPrototypes() as $prototype) {
  537. $this->assertNotEquals('void', $prototype->getReturnType(), var_export($prototype, 1));
  538. }
  539. }
  540. public function testCallingUnregisteredMethod()
  541. {
  542. $this->setExpectedException('Zend_XmlRpc_Server_Exception',
  543. 'Unknown instance method called on server: foobarbaz');
  544. $this->_server->foobarbaz();
  545. }
  546. public function testSetPersistenceDoesNothing()
  547. {
  548. $this->assertNull($this->_server->setPersistence('foo'));
  549. $this->assertNull($this->_server->setPersistence('whatever'));
  550. }
  551. public function testPassingInvalidRequestClassThrowsException()
  552. {
  553. $this->setExpectedException('Zend_XmlRpc_Server_Exception', 'Invalid request class');
  554. $this->_server->setRequest('stdClass');
  555. }
  556. public function testPassingInvalidResponseClassThrowsException()
  557. {
  558. $this->setExpectedException('Zend_XmlRpc_Server_Exception', 'Invalid response class');
  559. $this->_server->setResponseClass('stdClass');
  560. }
  561. public function testCreatingFaultWithEmptyMessageResultsInUnknownError()
  562. {
  563. $fault = $this->_server->fault('', 123);
  564. $this->assertSame('Unknown Error', $fault->getMessage());
  565. $this->assertSame(123, $fault->getCode());
  566. }
  567. }
  568. /**
  569. * Zend_XmlRpc_Server_testFunction
  570. *
  571. * Function for use with xmlrpc server unit tests
  572. *
  573. * @param array $var1
  574. * @param string $var2
  575. * @return string
  576. */
  577. function Zend_XmlRpc_Server_testFunction($var1, $var2 = 'optional')
  578. {
  579. return $var2 . ': ' . implode(',', (array) $var1);
  580. }
  581. /**
  582. * Zend_XmlRpc_Server_testFunction2
  583. *
  584. * Function for use with xmlrpc server unit tests
  585. *
  586. * @return string
  587. */
  588. function Zend_XmlRpc_Server_testFunction2()
  589. {
  590. return 'function2';
  591. }
  592. class Zend_XmlRpc_Server_testClass
  593. {
  594. private $_value1;
  595. private $_value2;
  596. /**
  597. * Constructor
  598. *
  599. * @return void
  600. */
  601. public function __construct($value1 = null, $value2 = null)
  602. {
  603. $this->_value1 = $value1;
  604. $this->_value2 = $value2;
  605. }
  606. /**
  607. * Test1
  608. *
  609. * Returns 'String: ' . $string
  610. *
  611. * @param string $string
  612. * @return string
  613. */
  614. public function test1($string)
  615. {
  616. return 'String: ' . (string) $string;
  617. }
  618. /**
  619. * Test2
  620. *
  621. * Returns imploded array
  622. *
  623. * @param array $array
  624. * @return string
  625. */
  626. public static function test2($array)
  627. {
  628. return implode('; ', (array) $array);
  629. }
  630. /**
  631. * Test3
  632. *
  633. * Should not be available...
  634. *
  635. * @return void
  636. */
  637. protected function _test3()
  638. {
  639. }
  640. /**
  641. * @param string $arg
  642. * @return struct
  643. */
  644. public function test4($arg)
  645. {
  646. return array('test1' => $this->_value1, 'test2' => $this->_value2, 'arg' => func_get_args());
  647. }
  648. /**
  649. * Test base64 encoding in request and response
  650. *
  651. * @param base64 $data
  652. * @return base64
  653. */
  654. public function base64($data)
  655. {
  656. return $data;
  657. }
  658. }
  659. class Zend_XmlRpc_Server_testResponse extends Zend_XmlRpc_Response
  660. {
  661. }
  662. class Zend_XmlRpc_Server_testRequest extends Zend_XmlRpc_Request
  663. {
  664. }
  665. // Call Zend_XmlRpc_ServerTest::main() if this source file is executed directly.
  666. if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_ServerTest::main") {
  667. Zend_XmlRpc_ServerTest::main();
  668. }