ServerTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  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. public function testSettingClassWithArguments()
  160. {
  161. $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test', 'argv-argument');
  162. $request = new Zend_XmlRpc_Request();
  163. $request->setMethod('test.test4');
  164. $response = $this->_server->handle($request);
  165. $this->assertNotType('Zend_XmlRpc_Fault', $response);
  166. $this->assertSame(
  167. array('test1' => 'argv-argument',
  168. 'test2' => null,
  169. 'arg' => array('argv-argument')),
  170. $response->getReturnValue());
  171. }
  172. /**
  173. * fault() test
  174. */
  175. public function testFault()
  176. {
  177. $fault = $this->_server->fault('This is a fault', 411);
  178. $this->assertTrue($fault instanceof Zend_XmlRpc_Server_Fault);
  179. $this->assertEquals(411, $fault->getCode());
  180. $this->assertEquals('This is a fault', $fault->getMessage());
  181. $fault = $this->_server->fault(new Zend_XmlRpc_Server_Exception('Exception fault', 511));
  182. $this->assertTrue($fault instanceof Zend_XmlRpc_Server_Fault);
  183. $this->assertEquals(511, $fault->getCode());
  184. $this->assertEquals('Exception fault', $fault->getMessage());
  185. }
  186. /**
  187. * handle() test
  188. *
  189. * Call as method call
  190. *
  191. * Expects:
  192. * - request: Optional;
  193. *
  194. * Returns: Zend_XmlRpc_Response|Zend_XmlRpc_Fault
  195. */
  196. public function testHandle()
  197. {
  198. $request = new Zend_XmlRpc_Request();
  199. $request->setMethod('system.listMethods');
  200. $response = $this->_server->handle($request);
  201. $this->assertTrue($response instanceof Zend_XmlRpc_Response);
  202. $return = $response->getReturnValue();
  203. $this->assertTrue(is_array($return));
  204. $this->assertTrue(in_array('system.multicall', $return));
  205. }
  206. /**
  207. * Test that only calling methods using a valid parameter signature works
  208. */
  209. public function testHandle2()
  210. {
  211. $request = new Zend_XmlRpc_Request();
  212. $request->setMethod('system.methodHelp');
  213. $response = $this->_server->handle($request);
  214. $this->assertTrue($response instanceof Zend_XmlRpc_Fault);
  215. $this->assertEquals(623, $response->getCode());
  216. }
  217. public function testCallingInvalidMethod()
  218. {
  219. $request = new Zend_XmlRpc_Request();
  220. $request->setMethod('invalid');
  221. $response = $this->_server->handle($request);
  222. $this->assertType('Zend_XmlRpc_Fault', $response);
  223. $this->assertSame('Method "invalid" does not exist', $response->getMessage());
  224. $this->assertSame(620, $response->getCode());
  225. }
  226. /**
  227. * setResponseClass() test
  228. *
  229. * Call as method call
  230. *
  231. * Expects:
  232. * - class:
  233. *
  234. * Returns: boolean
  235. */
  236. public function testSetResponseClass()
  237. {
  238. $this->assertTrue($this->_server->setResponseClass('Zend_XmlRpc_Server_testResponse'));
  239. $request = new Zend_XmlRpc_Request();
  240. $request->setMethod('system.listMethods');
  241. $response = $this->_server->handle($request);
  242. $this->assertTrue($response instanceof Zend_XmlRpc_Response);
  243. $this->assertTrue($response instanceof Zend_XmlRpc_Server_testResponse);
  244. }
  245. /**
  246. * listMethods() test
  247. *
  248. * Call as method call
  249. *
  250. * Returns: array
  251. */
  252. public function testListMethods()
  253. {
  254. $methods = $this->_server->listMethods();
  255. $this->assertTrue(is_array($methods));
  256. $this->assertTrue(in_array('system.listMethods', $methods));
  257. $this->assertTrue(in_array('system.methodHelp', $methods));
  258. $this->assertTrue(in_array('system.methodSignature', $methods));
  259. $this->assertTrue(in_array('system.multicall', $methods));
  260. }
  261. /**
  262. * methodHelp() test
  263. *
  264. * Call as method call
  265. *
  266. * Expects:
  267. * - method:
  268. *
  269. * Returns: string
  270. */
  271. public function testMethodHelp()
  272. {
  273. $help = $this->_server->methodHelp('system.methodHelp', 'system.listMethods');
  274. $this->assertContains('Display help message for an XMLRPC method', $help);
  275. $this->setExpectedException('Zend_XmlRpc_Server_Exception', 'Method "foo" does not exist');
  276. $this->_server->methodHelp('foo');
  277. }
  278. /**
  279. * methodSignature() test
  280. *
  281. * Call as method call
  282. *
  283. * Expects:
  284. * - method:
  285. *
  286. * Returns: array
  287. */
  288. public function testMethodSignature()
  289. {
  290. $sig = $this->_server->methodSignature('system.methodSignature');
  291. $this->assertTrue(is_array($sig));
  292. $this->assertEquals(1, count($sig), var_export($sig, 1));
  293. $this->setExpectedException('Zend_XmlRpc_Server_Exception', 'Method "foo" does not exist');
  294. $this->_server->methodSignature('foo');
  295. }
  296. /**
  297. * multicall() test
  298. *
  299. * Call as method call
  300. *
  301. * Expects:
  302. * - methods:
  303. *
  304. * Returns: array
  305. */
  306. public function testMulticall()
  307. {
  308. $struct = array(
  309. array(
  310. 'methodName' => 'system.listMethods',
  311. 'params' => array()
  312. ),
  313. array(
  314. 'methodName' => 'system.methodHelp',
  315. 'params' => array('system.multicall')
  316. )
  317. );
  318. $request = new Zend_XmlRpc_Request();
  319. $request->setMethod('system.multicall');
  320. $request->addParam($struct);
  321. $response = $this->_server->handle($request);
  322. $this->assertTrue($response instanceof Zend_XmlRpc_Response, $response->__toString() . "\n\n" . $request->__toString());
  323. $returns = $response->getReturnValue();
  324. $this->assertTrue(is_array($returns));
  325. $this->assertEquals(2, count($returns), var_export($returns, 1));
  326. $this->assertTrue(is_array($returns[0]), var_export($returns[0], 1));
  327. $this->assertTrue(is_string($returns[1]), var_export($returns[1], 1));
  328. }
  329. /**
  330. * Test get/setEncoding()
  331. */
  332. public function testGetSetEncoding()
  333. {
  334. $this->assertEquals('UTF-8', $this->_server->getEncoding());
  335. $this->_server->setEncoding('ISO-8859-1');
  336. $this->assertEquals('ISO-8859-1', $this->_server->getEncoding());
  337. }
  338. /**
  339. * Test request/response encoding
  340. */
  341. public function testRequestResponseEncoding()
  342. {
  343. $response = $this->_server->handle();
  344. $request = $this->_server->getRequest();
  345. $this->assertEquals('UTF-8', $request->getEncoding());
  346. $this->assertEquals('UTF-8', $response->getEncoding());
  347. }
  348. /**
  349. * Test request/response encoding (alternate encoding)
  350. */
  351. public function testRequestResponseEncoding2()
  352. {
  353. $this->_server->setEncoding('ISO-8859-1');
  354. $response = $this->_server->handle();
  355. $request = $this->_server->getRequest();
  356. $this->assertEquals('ISO-8859-1', $request->getEncoding());
  357. $this->assertEquals('ISO-8859-1', $response->getEncoding());
  358. }
  359. public function testAddFunctionWithExtraArgs()
  360. {
  361. $this->_server->addFunction('Zend_XmlRpc_Server_testFunction', 'test', 'arg1');
  362. $methods = $this->_server->listMethods();
  363. $this->assertContains('test.Zend_XmlRpc_Server_testFunction', $methods);
  364. }
  365. public function testAddFunctionThrowsExceptionWithBadData()
  366. {
  367. $o = new stdClass();
  368. try {
  369. $this->_server->addFunction($o);
  370. $this->fail('addFunction() should not accept objects');
  371. } catch (Zend_XmlRpc_Exception $e) {
  372. // success
  373. }
  374. }
  375. public function testLoadFunctionsThrowsExceptionWithBadData()
  376. {
  377. $o = new stdClass();
  378. try {
  379. $this->_server->loadFunctions($o);
  380. $this->fail('loadFunctions() should not accept objects');
  381. } catch (Zend_XmlRpc_Exception $e) {
  382. // success
  383. }
  384. try {
  385. $this->_server->loadFunctions('foo');
  386. $this->fail('loadFunctions() should not accept primitive values');
  387. } catch (Zend_XmlRpc_Server_Exception $e) {
  388. // success
  389. }
  390. $o = array($o);
  391. try {
  392. $this->_server->loadFunctions($o);
  393. $this->fail('loadFunctions() should not allow non-reflection objects in an array');
  394. } catch (Zend_Server_Exception $e) {
  395. $this->assertSame('Invalid method provided', $e->getMessage());
  396. }
  397. }
  398. public function testLoadFunctionsReadsMethodsFromServerDefinitionObjects()
  399. {
  400. $mockedMethod = $this->getMock('Zend_Server_Method_Definition', array(), array(), '', false,
  401. false);
  402. $mockedDefinition = $this->getMock('Zend_Server_Definition', array(), array(), '', false, false);
  403. $mockedDefinition->expects($this->once())
  404. ->method('getMethods')
  405. ->will($this->returnValue(array('bar' => $mockedMethod)));
  406. $this->_server->loadFunctions($mockedDefinition);
  407. }
  408. public function testSetClassThrowsExceptionWithInvalidClass()
  409. {
  410. try {
  411. $this->_server->setClass('mybogusclass');
  412. $this->fail('setClass() should not allow invalid classes');
  413. } catch (Zend_XmlRpc_Exception $e) {
  414. }
  415. }
  416. public function testSetRequestUsingString()
  417. {
  418. $this->_server->setRequest('Zend_XmlRpc_Server_testRequest');
  419. $req = $this->_server->getRequest();
  420. $this->assertTrue($req instanceof Zend_XmlRpc_Server_testRequest);
  421. }
  422. public function testSetRequestThrowsExceptionOnBadClass()
  423. {
  424. try {
  425. $this->_server->setRequest('Zend_XmlRpc_Server_testRequest2');
  426. $this->fail('Invalid request class should throw exception');
  427. } catch (Zend_XmlRpc_Exception $e) {
  428. // success
  429. }
  430. try {
  431. $this->_server->setRequest($this);
  432. $this->fail('Invalid request object should throw exception');
  433. } catch (Zend_XmlRpc_Exception $e) {
  434. // success
  435. }
  436. }
  437. public function testHandleObjectMethod()
  438. {
  439. $this->_server->setClass('Zend_XmlRpc_Server_testClass');
  440. $request = new Zend_XmlRpc_Request();
  441. $request->setMethod('test1');
  442. $request->addParam('value');
  443. $response = $this->_server->handle($request);
  444. $this->assertFalse($response instanceof Zend_XmlRpc_Fault);
  445. $this->assertEquals('String: value', $response->getReturnValue());
  446. }
  447. public function testHandleClassStaticMethod()
  448. {
  449. $this->_server->setClass('Zend_XmlRpc_Server_testClass');
  450. $request = new Zend_XmlRpc_Request();
  451. $request->setMethod('test2');
  452. $request->addParam(array('value1', 'value2'));
  453. $response = $this->_server->handle($request);
  454. $this->assertFalse($response instanceof Zend_XmlRpc_Fault);
  455. $this->assertEquals('value1; value2', $response->getReturnValue());
  456. }
  457. public function testHandleFunction()
  458. {
  459. $this->_server->addFunction('Zend_XmlRpc_Server_testFunction');
  460. $request = new Zend_XmlRpc_Request();
  461. $request->setMethod('Zend_XmlRpc_Server_testFunction');
  462. $request->setParams(array(array('value1'), 'key'));
  463. $response = $this->_server->handle($request);
  464. $this->assertFalse($response instanceof Zend_XmlRpc_Fault);
  465. $this->assertEquals('key: value1', $response->getReturnValue());
  466. }
  467. public function testMulticallReturnsFaultsWithBadData()
  468. {
  469. // bad method array
  470. $try = array(
  471. 'system.listMethods',
  472. array(
  473. 'name' => 'system.listMethods'
  474. ),
  475. array(
  476. 'methodName' => 'system.listMethods'
  477. ),
  478. array(
  479. 'methodName' => 'system.listMethods',
  480. 'params' => ''
  481. ),
  482. array(
  483. 'methodName' => 'system.multicall',
  484. 'params' => array()
  485. )
  486. );
  487. $returned = $this->_server->multicall($try);
  488. $this->assertTrue(is_array($returned));
  489. $this->assertEquals(5, count($returned));
  490. $response = $returned[0];
  491. $this->assertTrue(is_array($response));
  492. $this->assertTrue(isset($response['faultCode']));
  493. $this->assertEquals(601, $response['faultCode']);
  494. $response = $returned[1];
  495. $this->assertTrue(is_array($response));
  496. $this->assertTrue(isset($response['faultCode']));
  497. $this->assertEquals(602, $response['faultCode']);
  498. $response = $returned[2];
  499. $this->assertTrue(is_array($response));
  500. $this->assertTrue(isset($response['faultCode']));
  501. $this->assertEquals(603, $response['faultCode']);
  502. $response = $returned[3];
  503. $this->assertTrue(is_array($response));
  504. $this->assertTrue(isset($response['faultCode']));
  505. $this->assertEquals(604, $response['faultCode']);
  506. $response = $returned[4];
  507. $this->assertTrue(is_array($response));
  508. $this->assertTrue(isset($response['faultCode']));
  509. $this->assertEquals(605, $response['faultCode']);
  510. }
  511. /**
  512. * @see ZF-2872
  513. */
  514. public function testCanMarshalBase64Requests()
  515. {
  516. $this->_server->setClass('Zend_XmlRpc_Server_testClass', 'test');
  517. $data = base64_encode('this is the payload');
  518. $param = array('type' => 'base64', 'value' => $data);
  519. $request = new Zend_XmlRpc_Request('test.base64', array($param));
  520. $response = $this->_server->handle($request);
  521. $this->assertFalse($response instanceof Zend_XmlRpc_Fault);
  522. $this->assertEquals($data, $response->getReturnValue());
  523. }
  524. /**
  525. * @group ZF-6034
  526. */
  527. public function testPrototypeReturnValueMustReflectDocBlock()
  528. {
  529. $server = new Zend_XmlRpc_Server();
  530. $server->setClass('Zend_XmlRpc_Server_testClass');
  531. $table = $server->getDispatchTable();
  532. $method = $table->getMethod('test1');
  533. foreach ($method->getPrototypes() as $prototype) {
  534. $this->assertNotEquals('void', $prototype->getReturnType(), var_export($prototype, 1));
  535. }
  536. }
  537. public function testCallingUnregisteredMethod()
  538. {
  539. $this->setExpectedException('Zend_XmlRpc_Server_Exception',
  540. 'Unknown instance method called on server: foobarbaz');
  541. $this->_server->foobarbaz();
  542. }
  543. public function testSetPersistenceDoesNothing()
  544. {
  545. $this->assertNull($this->_server->setPersistence('foo'));
  546. $this->assertNull($this->_server->setPersistence('whatever'));
  547. }
  548. public function testPassingInvalidRequestClassThrowsException()
  549. {
  550. $this->setExpectedException('Zend_XmlRpc_Server_Exception', 'Invalid request class');
  551. $this->_server->setRequest('stdClass');
  552. }
  553. public function testPassingInvalidResponseClassThrowsException()
  554. {
  555. $this->setExpectedException('Zend_XmlRpc_Server_Exception', 'Invalid response class');
  556. $this->_server->setResponseClass('stdClass');
  557. }
  558. public function testCreatingFaultWithEmptyMessageResultsInUnknownError()
  559. {
  560. $fault = $this->_server->fault('', 123);
  561. $this->assertSame('Unknown Error', $fault->getMessage());
  562. $this->assertSame(123, $fault->getCode());
  563. }
  564. }
  565. /**
  566. * Zend_XmlRpc_Server_testFunction
  567. *
  568. * Function for use with xmlrpc server unit tests
  569. *
  570. * @param array $var1
  571. * @param string $var2
  572. * @return string
  573. */
  574. function Zend_XmlRpc_Server_testFunction($var1, $var2 = 'optional')
  575. {
  576. return $var2 . ': ' . implode(',', (array) $var1);
  577. }
  578. /**
  579. * Zend_XmlRpc_Server_testFunction2
  580. *
  581. * Function for use with xmlrpc server unit tests
  582. *
  583. * @return string
  584. */
  585. function Zend_XmlRpc_Server_testFunction2()
  586. {
  587. return 'function2';
  588. }
  589. class Zend_XmlRpc_Server_testClass
  590. {
  591. private $_value1;
  592. private $_value2;
  593. /**
  594. * Constructor
  595. *
  596. * @return void
  597. */
  598. public function __construct($value1 = null, $value2 = null)
  599. {
  600. $this->_value1 = $value1;
  601. $this->_value2 = $value2;
  602. }
  603. /**
  604. * Test1
  605. *
  606. * Returns 'String: ' . $string
  607. *
  608. * @param string $string
  609. * @return string
  610. */
  611. public function test1($string)
  612. {
  613. return 'String: ' . (string) $string;
  614. }
  615. /**
  616. * Test2
  617. *
  618. * Returns imploded array
  619. *
  620. * @param array $array
  621. * @return string
  622. */
  623. public static function test2($array)
  624. {
  625. return implode('; ', (array) $array);
  626. }
  627. /**
  628. * Test3
  629. *
  630. * Should not be available...
  631. *
  632. * @return void
  633. */
  634. protected function _test3()
  635. {
  636. }
  637. /**
  638. * @param string $arg
  639. * @return struct
  640. */
  641. public function test4($arg)
  642. {
  643. return array('test1' => $this->_value1, 'test2' => $this->_value2, 'arg' => func_get_args());
  644. }
  645. /**
  646. * Test base64 encoding in request and response
  647. *
  648. * @param base64 $data
  649. * @return base64
  650. */
  651. public function base64($data)
  652. {
  653. return $data;
  654. }
  655. }
  656. class Zend_XmlRpc_Server_testResponse extends Zend_XmlRpc_Response
  657. {
  658. }
  659. class Zend_XmlRpc_Server_testRequest extends Zend_XmlRpc_Request
  660. {
  661. }
  662. // Call Zend_XmlRpc_ServerTest::main() if this source file is executed directly.
  663. if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_ServerTest::main") {
  664. Zend_XmlRpc_ServerTest::main();
  665. }