Skip to content

Commit

Permalink
Provide all execution results for HTML and full Stryker reports (#1637)
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-rafalko committed Jan 8, 2022
1 parent a9c38ea commit 7b92b2c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Metrics/TargetDetectionStatusesProvider.php
Expand Up @@ -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;
Expand Down
53 changes: 53 additions & 0 deletions tests/phpunit/Metrics/TargetDetectionStatusesProviderTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7b92b2c

Please sign in to comment.