diff --git a/src/Config.php b/src/Config.php index df56ecf92d..22c75b7e28 100644 --- a/src/Config.php +++ b/src/Config.php @@ -1010,8 +1010,8 @@ public function processLongArgument($arg, $pos) } self::$overriddenDefaults['stdinPath'] = true; - } else if (PHP_CODESNIFFER_CBF === false && substr($arg, 0, 12) === 'report-file=') { - if (isset(self::$overriddenDefaults['reportFile']) === true) { + } else if (substr($arg, 0, 12) === 'report-file=') { + if (PHP_CODESNIFFER_CBF === true || isset(self::$overriddenDefaults['reportFile']) === true) { break; } diff --git a/tests/Core/Config/ReportArgsTest.php b/tests/Core/Config/ReportArgsTest.php new file mode 100644 index 0000000000..60b5a7c46e --- /dev/null +++ b/tests/Core/Config/ReportArgsTest.php @@ -0,0 +1,64 @@ +markTestSkipped('This test needs CS mode to run'); + } + + $config = new ConfigDouble(['--report-file='.__DIR__.'/report.txt']); + + $this->assertTrue(is_string($config->reportFile)); + $this->assertStringEndsWith('/report.txt', $config->reportFile); + $this->assertSame(['full' => null], $config->reports); + + }//end testReportFileDoesNotSetReportsCs() + + + /** + * [CBF mode] Verify that passing `--report-file` does not influence *which* reports get activated. + * + * @group CBF + * + * @return void + */ + public function testReportFileDoesNotSetReportsCbf() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $config = new ConfigDouble(['--report-file='.__DIR__.'/report.txt']); + + $this->assertNull($config->reportFile); + $this->assertSame(['full' => null], $config->reports); + + }//end testReportFileDoesNotSetReportsCbf() + + +}//end class