1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-30 18:00:17 +02:00

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.
This commit is contained in:
Jonathan Campbell
2024-06-28 04:41:10 -04:00
committed by GitHub
parent 47e301d3e2
commit 4e03d25f6d

View File

@@ -68,7 +68,7 @@ class IntrospectionProcessorTest extends TestCase
{
$input = $this->getRecord(Level::Debug);
$expected = $input;
$expected = clone $input;
$processor = new IntrospectionProcessor(Level::Critical);
$actual = $processor($input);
@@ -80,7 +80,7 @@ class IntrospectionProcessorTest extends TestCase
{
$input = $this->getRecord(Level::Critical);
$expected = $input;
$expected = clone $input;
$expected['extra'] = [
'file' => null,
'line' => null,
@@ -99,7 +99,7 @@ class IntrospectionProcessorTest extends TestCase
{
$input = $this->getRecord(Level::Emergency);
$expected = $input;
$expected = clone $input;
$expected['extra'] = [
'file' => null,
'line' => null,