From 4e03d25f6ddceff5f567d9f4758c7b63e9d7b2d2 Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Fri, 28 Jun 2024 04:41:10 -0400 Subject: [PATCH] Fix IntrospectionProcessor tests that were not validating the code under test (#1896) Three tests in IntrospectionProcessorTest (testLevelTooLow, testLevelEqual, testLevelHigher) aren't actually testing anything. Because `$expected = $input` is a reference, the changes made to `$expected['extra']` are made to $input and carried forward to $actual. You can demonstrate this by adding a `return $record` at the immediate start of `InstrospectionProcessor::__invoke` -- the tests still pass despite bypassing all the code. --- tests/Monolog/Processor/IntrospectionProcessorTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Monolog/Processor/IntrospectionProcessorTest.php b/tests/Monolog/Processor/IntrospectionProcessorTest.php index d18dbd00a..a967ee1f7 100644 --- a/tests/Monolog/Processor/IntrospectionProcessorTest.php +++ b/tests/Monolog/Processor/IntrospectionProcessorTest.php @@ -68,7 +68,7 @@ public function testLevelTooLow() { $input = $this->getRecord(Level::Debug); - $expected = $input; + $expected = clone $input; $processor = new IntrospectionProcessor(Level::Critical); $actual = $processor($input); @@ -80,7 +80,7 @@ public function testLevelEqual() { $input = $this->getRecord(Level::Critical); - $expected = $input; + $expected = clone $input; $expected['extra'] = [ 'file' => null, 'line' => null, @@ -99,7 +99,7 @@ public function testLevelHigher() { $input = $this->getRecord(Level::Emergency); - $expected = $input; + $expected = clone $input; $expected['extra'] = [ 'file' => null, 'line' => null,