public function testFaultWithoutException() { $server = new Zend_Rest_Server(); $fault = $server->fault('testing fault'); $this->assertTrue($fault instanceof DOMDocument); $sx = simplexml_import_dom($fault); $this->assertTrue(isset($sx->response)); $this->assertTrue(isset($sx->response->message)); $this->assertContains('An unknown error occured. Please try again.', (string) $sx->response->message); }
function testHandleException() { $server = new Zend_Rest_Server(); $server->addFunction('Zend_Rest_Server_TestFunc10'); ob_start(); $server->handle(array('method' => 'Zend_Rest_Server_TestFunc10')); ob_end_clean(); ob_start(); $server->fault(new Exception('An error occurred.', 404)); $result = ob_get_clean(); $this->assertEquals("<Zend_Rest_Server_TestFunc10 generator='zend' version='1.0'><response><message>An error occurred.</message></response><status>failed</status></Zend_Rest_Server_TestFunc10>", $result, "Bad Response"); }