function testHandleReturnObject() { $server = new Zend_Json_Server(); $server->addFunction('Zend_Json_Server_TestFunc8'); ob_start(); $server->handle(array('method' => 'Zend_Json_Server_TestFunc8')); $result = ob_get_clean(); $this->assertEquals('{"__className": "stdClass", "foo" : "bar", "baz" : true, "bat" : 123, "qux" : false, "status" : "success"}', $result, "Bas Response"); }
function testHandleException() { $server = new Zend_Json_Server(); $server->addFunction('Zend_Json_Server_TestFunc10'); ob_start(); $server->handle(array('method' => 'Zend_Json_Server_TestFunc10')); ob_end_clean(); ob_start(); $server->fault(new Exception('An error occurred.', 404)); $result = ob_get_clean(); $this->assertEquals('{"msg" : "An error occurred.", "code" : 404}', $result, "Bad Response"); }