diff --git a/src/Metrics/TargetDetectionStatusesProvider.php b/src/Metrics/TargetDetectionStatusesProvider.php index 7c38e5f16..21b83b094 100644 --- a/src/Metrics/TargetDetectionStatusesProvider.php +++ b/src/Metrics/TargetDetectionStatusesProvider.php @@ -112,7 +112,9 @@ private function findRequired(): Generator } // HTML logger needs all mutation results to make a summary. - if ($this->logConfig->getHtmlLogFilePath() !== null) { + $strykerConfig = $this->logConfig->getStrykerConfig(); + + if ($this->logConfig->getHtmlLogFilePath() !== null || ($strykerConfig !== null && $strykerConfig->isForFullReport())) { yield from DetectionStatus::ALL; return; diff --git a/tests/phpunit/Metrics/TargetDetectionStatusesProviderTest.php b/tests/phpunit/Metrics/TargetDetectionStatusesProviderTest.php index 4ec688b86..acb66729a 100644 --- a/tests/phpunit/Metrics/TargetDetectionStatusesProviderTest.php +++ b/tests/phpunit/Metrics/TargetDetectionStatusesProviderTest.php @@ -37,6 +37,7 @@ use function array_keys; use Infection\Configuration\Entry\Logs; +use Infection\Configuration\Entry\StrykerConfig; use Infection\Console\LogVerbosity; use Infection\Metrics\TargetDetectionStatusesProvider; use Infection\Mutant\DetectionStatus; @@ -196,6 +197,58 @@ public function test_it_provides_certain_statuses_including_not_covered_for_json ], $provider->get()); } + public function test_it_provides_all_statuses_for_html_logger(): void + { + $logs = $this->createMock(Logs::class); + $logs + ->expects($this->once()) + ->method('getHtmlLogFilePath') + ->willReturn('infection.html') + ; + + $provider = new TargetDetectionStatusesProvider($logs, LogVerbosity::NORMAL, true, false); + + $this->assertProvidesExcluding([], $provider->get()); + } + + public function test_it_provides_all_statuses_for_full_stryker_report(): void + { + $logs = $this->createMock(Logs::class); + $logs + ->expects($this->once()) + ->method('getHtmlLogFilePath') + ->willReturn(null) + ; + $logs + ->expects($this->once()) + ->method('getStrykerConfig') + ->willReturn(StrykerConfig::forFullReport('master')) + ; + + $provider = new TargetDetectionStatusesProvider($logs, LogVerbosity::NORMAL, true, false); + + $this->assertProvidesExcluding([], $provider->get()); + } + + public function test_it_provides_nothing_for_stryker_badge_report(): void + { + $logs = $this->createMock(Logs::class); + $logs + ->expects($this->once()) + ->method('getHtmlLogFilePath') + ->willReturn(null) + ; + $logs + ->expects($this->once()) + ->method('getStrykerConfig') + ->willReturn(StrykerConfig::forBadge('master')) + ; + + $provider = new TargetDetectionStatusesProvider($logs, LogVerbosity::NORMAL, true, false); + + $this->assertSame([], $provider->get()); + } + private function assertProvides(array $expected, array $actual): void { $expected = array_flip($expected);