Browse Source

Adding tests for previous commit.
Refs #1678

mark_story 15 years ago
parent
commit
cd13e37609
1 changed files with 24 additions and 0 deletions
  1. 24 0
      lib/Cake/Test/Case/Error/ExceptionRendererTest.php

+ 24 - 0
lib/Cake/Test/Case/Error/ExceptionRendererTest.php

@@ -636,4 +636,28 @@ class ExceptionRendererTest extends CakeTestCase {
 		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);
+	}
 }