From cd13e376095489a304dbc197c60d80c9227d4b70 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 16 May 2011 21:12:28 -0400 Subject: [PATCH] Adding tests for previous commit. Refs #1678 --- .../Test/Case/Error/ExceptionRendererTest.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php index ac4484b2b2e..70d537518f0 100644 --- a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php +++ b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php @@ -636,4 +636,28 @@ function testMissingRenderSafe() { sort($ExceptionRenderer->controller->helpers); $this->assertEquals(array('Form', 'Html', 'Session'), $ExceptionRenderer->controller->helpers); } + +/** + * Test that exceptions can be rendered when an request hasn't been registered + * with Router + * + * @return void + */ + 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); + } }