Explorar el Código

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.
Jonathan Campbell hace 1 año
padre
commit
4e03d25f6d
Se han modificado 1 ficheros con 3 adiciones y 3 borrados
  1. 3 3
      tests/Monolog/Processor/IntrospectionProcessorTest.php

+ 3 - 3
tests/Monolog/Processor/IntrospectionProcessorTest.php

@@ -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,