Skip to content

Commit

Permalink
Fix IntrospectionProcessor tests that were not validating the code un…
Browse files Browse the repository at this point in the history
…der 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.
  • Loading branch information
healsdata committed Jun 28, 2024
1 parent 47e301d commit 4e03d25
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/Monolog/Processor/IntrospectionProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -80,7 +80,7 @@ public function testLevelEqual()
{
$input = $this->getRecord(Level::Critical);

$expected = $input;
$expected = clone $input;
$expected['extra'] = [
'file' => null,
'line' => null,
Expand All @@ -99,7 +99,7 @@ public function testLevelHigher()
{
$input = $this->getRecord(Level::Emergency);

$expected = $input;
$expected = clone $input;
$expected['extra'] = [
'file' => null,
'line' => null,
Expand Down

0 comments on commit 4e03d25

Please sign in to comment.