Skip to content

Commit

Permalink
Adding tests for previous commit.
Browse files Browse the repository at this point in the history
Refs #1678
  • Loading branch information
markstory committed May 17, 2011
1 parent 2bc58a5 commit cd13e37
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/Cake/Test/Case/Error/ExceptionRendererTest.php
Expand Up @@ -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);
}
}

1 comment on commit cd13e37

@tPl0ch
Copy link

@tPl0ch tPl0ch commented on cd13e37 May 17, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know, I didn't have a clue on how to write a test for this :)

Please sign in to comment.