From a5f6b6c8eed22e853756a722ade5888d98a16f0b Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Sat, 7 Jan 2023 15:54:44 +0900 Subject: [PATCH] test: Attempting to read an undefined variable causes a Warning error (PHP 8.0+) see: https://www.php.net/manual/en/migration80.incompatible.php --- lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index 50266c13e..4e21318ae 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -109,8 +109,8 @@ class ErrorHandlerTest extends CakeTestCase { $result = ob_get_clean(); $this->assertMatchesRegularExpression('/
/', $result);
-		$this->assertMatchesRegularExpression('/Notice<\/b>/', $result);
-		$this->assertMatchesRegularExpression('/variable:\s+wrong/', $result);
+		$this->assertMatchesRegularExpression('/Warning<\/b>/', $result);
+		$this->assertMatchesRegularExpression('/variable\s+\$wrong/', $result);
 	}
 
 /**
@@ -169,8 +169,8 @@ class ErrorHandlerTest extends CakeTestCase {
 	public function testHandleErrorDebugOff() {
 		Configure::write('debug', 0);
 		Configure::write('Error.trace', false);
-		if (file_exists(LOGS . 'debug.log')) {
-			unlink(LOGS . 'debug.log');
+		if (file_exists(LOGS . 'error.log')) {
+			unlink(LOGS . 'error.log');
 		}
 
 		set_error_handler('ErrorHandler::handleError');
@@ -178,10 +178,10 @@ class ErrorHandlerTest extends CakeTestCase {
 
 		$out .= '';
 
-		$result = file(LOGS . 'debug.log');
+		$result = file(LOGS . 'error.log');
 		$this->assertEquals(1, count($result));
 		$this->assertMatchesRegularExpression(
-			'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (Notice|Debug): Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/',
+			'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Warning: Warning \(2\): Undefined variable\s+\$out in \[.+ line \d+\]$/',
 			$result[0]
 		);
 		if (file_exists(LOGS . 'debug.log')) {
@@ -197,8 +197,8 @@ class ErrorHandlerTest extends CakeTestCase {
 	public function testHandleErrorLoggingTrace() {
 		Configure::write('debug', 0);
 		Configure::write('Error.trace', true);
-		if (file_exists(LOGS . 'debug.log')) {
-			unlink(LOGS . 'debug.log');
+		if (file_exists(LOGS . 'error.log')) {
+			unlink(LOGS . 'error.log');
 		}
 
 		set_error_handler('ErrorHandler::handleError');
@@ -206,9 +206,9 @@ class ErrorHandlerTest extends CakeTestCase {
 
 		$out .= '';
 
-		$result = file(LOGS . 'debug.log');
+		$result = file(LOGS . 'error.log');
 		$this->assertMatchesRegularExpression(
-			'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (Notice|Debug): Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/',
+			'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Warning: Warning \(2\): Undefined variable\s+\$out in \[.+ line \d+\]$/',
 			$result[0]
 		);
 		$this->assertMatchesRegularExpression('/^Trace:/', $result[1]);