Skip to content

Commit cd13e37

Browse files
committed
Adding tests for previous commit.
Refs #1678
1 parent 2bc58a5 commit cd13e37

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/Cake/Test/Case/Error/ExceptionRendererTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,4 +636,28 @@ function testMissingRenderSafe() {
636636
sort($ExceptionRenderer->controller->helpers);
637637
$this->assertEquals(array('Form', 'Html', 'Session'), $ExceptionRenderer->controller->helpers);
638638
}
639+
640+
/**
641+
* Test that exceptions can be rendered when an request hasn't been registered
642+
* with Router
643+
*
644+
* @return void
645+
*/
646+
function testRenderWithNoRequest() {
647+
Router::reload();
648+
$this->assertNull(Router::getRequest(false));
649+
650+
$exception = new Exception('Terrible');
651+
$ExceptionRenderer = new ExceptionRenderer($exception);
652+
$ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader'));
653+
$ExceptionRenderer->controller->response->expects($this->once())
654+
->method('statusCode')
655+
->with(500);
656+
657+
ob_start();
658+
$ExceptionRenderer->render();
659+
$result = ob_get_clean();
660+
661+
$this->assertContains('Internal Error', $result);
662+
}
639663
}

0 commit comments

Comments
 (0)