/** * @brief set the layout based on the user type */ public function render() { $this->controller->layout = 'error'; if (isset($this->controller->request['params']['admin']) && $this->controller->request['params']['admin']) { $this->controller->layout = 'admin_error'; } $this->controller->viewClass = 'Libs.Infinitas'; parent::render(); }
public function render() { $this->controller->set('title_for_layout', __('Error!')); if (TEST_ENV) { parent::render(); } else { if ($this->method !== 'error500') { $this->method = 'error400'; } parent::render(); } }
public function render() { $this->controller->set('title_for_layout', __('Error!')); if (Configure::read('debug') == 2) { parent::render(); } else { if ($this->method !== 'error500') { $this->method = 'error400'; } parent::render(); } }
public function render() { if ($this->error instanceof MP\ApiConnectionException) { $url = $this->controller->request->here(); $code = 500; $this->controller->response->statusCode($code); $this->controller->set(array('code' => $code, 'url' => h($url), 'name' => h($this->error->getMessage()), 'error' => $this->error, '_serialize' => array('code', 'url', 'name', 'error'))); $this->template = str_replace('mP\\', 'mp/', $this->template); $this->_outputMessage($this->template); } elseif ($this->error instanceof MissingControllerException) { if (is_numeric($this->controller->request->params['action'])) { $url = '/dane' . $this->controller->request->here(); $this->controller->redirect($url); } else { return parent::render(); } } else { return parent::render(); } }
/** * Test that exceptions can be rendered when an request hasn't been registered * with Router * * @return void */ public function testRenderWithNoRequest() { Router::reload(); $this->assertNull(Router::getRequest(false)); $exception = new Exception('Terrible'); $ExceptionRenderer = new ExceptionRenderer($exception); $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); $ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(500); ob_start(); $ExceptionRenderer->render(); $result = ob_get_clean(); $this->assertContains('Internal Error', $result); }
/** * Tests the output of rendering a PDOException * * @return void */ public function testPDOException() { $exception = new PDOException('There was an error in the SQL query'); $exception->queryString = 'SELECT * from poo_query < 5 and :seven'; $exception->params = array('seven' => 7); $ExceptionRenderer = new ExceptionRenderer($exception); $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); $ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(500); ob_start(); $ExceptionRenderer->render(); $result = ob_get_clean(); $this->assertContains('<h2>Database Error</h2>', $result); $this->assertContains('There was an error in the SQL query', $result); $this->assertContains(h('SELECT * from poo_query < 5 and :seven'), $result); $this->assertContains("'seven' => (int) 7", $result); }
/** * Test that rendering exceptions triggers shutdown events. * * @return void */ public function testRenderShutdownEvents() { $fired = array(); $listener = function ($event) use(&$fired) { $fired[] = $event->name(); }; $EventManager = CakeEventManager::instance(); $EventManager->attach($listener, 'Controller.shutdown'); $EventManager->attach($listener, 'Dispatcher.afterDispatch'); $exception = new Exception('Terrible'); $ExceptionRenderer = new ExceptionRenderer($exception); ob_start(); $ExceptionRenderer->render(); ob_get_clean(); $expected = array('Controller.shutdown', 'Dispatcher.afterDispatch'); $this->assertEquals($expected, $fired); }
/** * Test the various CakeException sub classes * * @dataProvider testProvider * @return void */ function testCakeExceptionHandling($exception, $patterns, $code) { $ExceptionRenderer = new ExceptionRenderer($exception); $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); $ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with($code); ob_start(); $ExceptionRenderer->render(); $result = ob_get_clean(); foreach ($patterns as $pattern) { $this->assertPattern($pattern, $result); } }