コード例 #1
0
 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");
 }
コード例 #2
0
 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");
 }