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.
This commit is contained in:
Renan Gonçalves 2012-09-14 14:17:07 +02:00
parent 7d2cbec79d
commit d33f676ddd
2 changed files with 21 additions and 0 deletions

View file

@ -84,6 +84,10 @@ class ConsoleErrorHandler {
if (Configure::read('debug') == 0) { if (Configure::read('debug') == 0) {
CakeLog::write($log, $message); CakeLog::write($log, $message);
} }
if ($log === LOG_ERR) {
$this->_stop(1);
}
} }
/** /**

View file

@ -60,6 +60,23 @@ class ConsoleErrorHandlerTest extends CakeTestCase {
$this->Error->handleError(E_NOTICE, 'This is a notice error', '/some/file', 275); $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. * test that the console error handler can deal with CakeExceptions.
* *