Permalink
Browse files

Handling a fatal error on console should call Shell::_stop(1).

Just like we do on web, any exception or fatal error will result into a InternalErrorException/FatalErrorException.
  • Loading branch information...
renan committed Sep 14, 2012
1 parent 7d2cbec commit d33f676ddd72b798fba3aff6fdf58ba1a7bdf445
Showing with 21 additions and 0 deletions.
  1. +4 −0 lib/Cake/Console/ConsoleErrorHandler.php
  2. +17 −0 lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php
@@ -84,6 +84,10 @@ public function handleError($code, $description, $file = null, $line = null, $co
if (Configure::read('debug') == 0) {
CakeLog::write($log, $message);
}
+
+ if ($log === LOG_ERR) {
+ $this->_stop(1);
+ }
}
/**
@@ -60,6 +60,23 @@ public function testHandleError() {
$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 = "<error>Fatal Error 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.
*

0 comments on commit d33f676

Please sign in to comment.