/** * get/loadFunctions() test */ public function testFunctions() { $expected = $this->_server->listMethods(); $functions = $this->_server->getFunctions(); $server = new Server(); $server->loadFunctions($functions); $actual = $server->listMethods(); $this->assertSame($expected, $actual); }
/** * Cache a file containing the dispatch list. * * Serializes the XMLRPC server callbacks array and stores the information * in Zend_Cache_Core * * @param string $id * @param Zend_Cache_Core $coreCache * @param Zend_XmlRpc_Server $server * @return bool */ public static function save($id, Zend_Cache_Core $coreCache, Zend_XmlRpc_Server $server) { // Get function list $methods = $server->getFunctions(); // Remove system.* methods foreach ($methods as $name => $method) { if ($method->system) { unset($methods[$name]); } } // Store return (bool) $coreCache->save(serialize($methods), $id, array(), null); }
/** * get/loadFunctions() test */ public function testFunctions() { try { $this->_server->addFunction(array('Zend_XmlRpc_Server_testFunction', 'Zend_XmlRpc_Server_testFunction2'), 'zsr'); } catch (Zend_XmlRpc_Exception $e) { $this->fail('Error attaching functions: ' . $e->getMessage()); } $expected = $this->_server->listMethods(); $functions = $this->_server->getFunctions(); $server = new Zend_XmlRpc_Server(); $server->loadFunctions($functions); $actual = $server->listMethods(); $this->assertSame($expected, $actual); }
/** * Cache a file containing the dispatch list. * * Serializes the XMLRPC server callbacks array and stores the information * in $filename. * * Returns false on any error (typically, inability to write to file), true * on success. * * @param string $filename * @param Zend_XmlRpc_Server $server * @return bool */ public static function save($filename, Zend_XmlRpc_Server $server) { if (!is_string($filename) || !file_exists($filename) && !is_writable(dirname($filename))) { return false; } // Remove system.* methods $methods = $server->getFunctions(); foreach ($methods as $name => $method) { if ($method->system) { unset($methods[$name]); } } // Store if (0 === @file_put_contents($filename, serialize($methods))) { return false; } return true; }