function test_error() { $r = new Restful(); $correct = json_encode((object) array('success' => false, 'error' => 'Error message')); ob_start(); $res = $r->error('Error message'); $out = ob_get_clean(); $this->assertEquals(null, $res); $this->assertEquals($out, $correct); }
/** * Returns a RESTful error response. */ public function restful_error($message, $code = null) { // Disable page layout and set JSON header. $this->_page->layout = false; $this->header('Content-Type: application/json'); $r = new Restful(); $r->controller = $this; return $r->error($message, $code); }