diff --git a/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index 043c62125..e7409e891 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -84,6 +84,10 @@ class ConsoleErrorHandler { if (Configure::read('debug') == 0) { CakeLog::write($log, $message); } + + if ($log === LOG_ERR) { + $this->_stop(1); + } } /** diff --git a/lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php b/lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php index ef24dcbcf..32cddd4b0 100644 --- a/lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php @@ -60,6 +60,23 @@ class ConsoleErrorHandlerTest extends CakeTestCase { $this->Error->handleError(E_NOTICE, 'This is a notice error', '/some/file', 275); } +/** + * test that the console error handler can deal with fatal errors. + * + * @return void + */ + public function testHandleFatalError() { + $content = "Fatal Error Error: This is a fatal error in [/some/file, line 275]\n"; + ConsoleErrorHandler::$stderr->expects($this->once())->method('write') + ->with($content); + + $this->Error->expects($this->once()) + ->method('_stop') + ->with(1); + + $this->Error->handleError(E_USER_ERROR, 'This is a fatal error', '/some/file', 275); + } + /** * test that the console error handler can deal with CakeExceptions. *