public function testHandleFunction() { $this->_server->addFunction('ZendTest\\XmlRpc\\testFunction'); $request = new Request(); $request->setMethod('ZendTest\\XmlRpc\\testFunction'); $request->setParams(array(array('value1'), 'key')); $response = $this->_server->handle($request); $this->assertFalse($response instanceof Fault); $this->assertEquals('key: value1', $response->getReturnValue()); }
/** * addFunction() test * * Call as method call * * Expects: * - function: * - namespace: Optional; has default; * * Returns: void */ public function testAddFunction() { try { $this->_server->addFunction('ZendTest\\XmlRpc\\testFunction', 'zsr'); } catch (XmlRpc\Exception $e) { $this->fail('Attachment should have worked'); } $methods = $this->_server->listMethods(); $this->assertTrue(in_array('zsr.ZendTest\\XmlRpc\\testFunction', $methods), var_export($methods, 1)); try { $this->_server->addFunction('nosuchfunction'); $this->fail('nosuchfunction() should not exist and should throw an exception'); } catch (XmlRpc\Exception $e) { // do nothing } $server = new Server(); try { $server->addFunction(array('ZendTest\\XmlRpc\\testFunction', 'ZendTest\\XmlRpc\\testFunction2'), 'zsr'); } catch (XmlRpc\Exception $e) { $this->fail('Error attaching array of functions: ' . $e->getMessage()); } $methods = $server->listMethods(); $this->assertTrue(in_array('zsr.ZendTest\\XmlRpc\\testFunction', $methods)); $this->assertTrue(in_array('zsr.ZendTest\\XmlRpc\\testFunction2', $methods)); }