test: Allow ErrorHandlerTest to run even if CakeLog configs (stdout and stderr) are not configured.

When ErrorHandlerTest is run with CakeTestRunner (TestShell) (or run with ShellTest, etc.), these configs are provided in the initialization process of the Shell class, but are not needed in many test cases.
This commit is contained in:
Koji Tanaka 2023-01-07 15:35:03 +09:00 committed by Kamil Wylegala
parent b46b6c758f
commit 76d1673958

View file

@ -66,8 +66,12 @@ class ErrorHandlerTest extends CakeTestCase {
Router::setRequestInfo($request); Router::setRequestInfo($request);
Configure::write('debug', 2); Configure::write('debug', 2);
CakeLog::disable('stdout'); if (CakeLog::stream('stdout') !== false) {
CakeLog::disable('stderr'); CakeLog::disable('stdout');
}
if (CakeLog::stream('stderr') !== false) {
CakeLog::disable('stderr');
}
} }
/** /**
@ -80,8 +84,13 @@ class ErrorHandlerTest extends CakeTestCase {
if ($this->_restoreError) { if ($this->_restoreError) {
restore_error_handler(); restore_error_handler();
} }
CakeLog::enable('stdout');
CakeLog::enable('stderr'); if (CakeLog::stream('stdout') !== false) {
CakeLog::enable('stdout');
}
if (CakeLog::stream('stderr') !== false) {
CakeLog::enable('stderr');
}
} }
/** /**