Skip to content

Commit 4e03d25

Browse files
authored
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.
1 parent 47e301d commit 4e03d25

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/Monolog/Processor/IntrospectionProcessorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testLevelTooLow()
6868
{
6969
$input = $this->getRecord(Level::Debug);
7070

71-
$expected = $input;
71+
$expected = clone $input;
7272

7373
$processor = new IntrospectionProcessor(Level::Critical);
7474
$actual = $processor($input);
@@ -80,7 +80,7 @@ public function testLevelEqual()
8080
{
8181
$input = $this->getRecord(Level::Critical);
8282

83-
$expected = $input;
83+
$expected = clone $input;
8484
$expected['extra'] = [
8585
'file' => null,
8686
'line' => null,
@@ -99,7 +99,7 @@ public function testLevelHigher()
9999
{
100100
$input = $this->getRecord(Level::Emergency);
101101

102-
$expected = $input;
102+
$expected = clone $input;
103103
$expected['extra'] = [
104104
'file' => null,
105105
'line' => null,

0 commit comments

Comments
 (0)