mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
7d2cbec79d
commit
d33f676ddd
2 changed files with 21 additions and 0 deletions
|
@ -84,6 +84,10 @@ class ConsoleErrorHandler {
|
|||
if (Configure::read('debug') == 0) {
|
||||
CakeLog::write($log, $message);
|
||||
}
|
||||
|
||||
if ($log === LOG_ERR) {
|
||||
$this->_stop(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 = "<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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue