Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide all execution results for HTML and full Stryker reports #1637

Merged
merged 1 commit into from Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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