From 76d167395870e30c017db76e71199c434118c666 Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Sat, 7 Jan 2023 15:35:03 +0900 Subject: [PATCH] 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. --- lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index 9fc619fc8..50266c13e 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -66,8 +66,12 @@ class ErrorHandlerTest extends CakeTestCase { Router::setRequestInfo($request); Configure::write('debug', 2); - CakeLog::disable('stdout'); - CakeLog::disable('stderr'); + if (CakeLog::stream('stdout') !== false) { + CakeLog::disable('stdout'); + } + if (CakeLog::stream('stderr') !== false) { + CakeLog::disable('stderr'); + } } /** @@ -80,8 +84,13 @@ class ErrorHandlerTest extends CakeTestCase { if ($this->_restoreError) { 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'); + } } /**