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

Create MutationExecutionResult instance with real path always, not mixed #1652

Merged
merged 1 commit into from Jan 20, 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
3 changes: 3 additions & 0 deletions src/Logger/Html/StrykerHtmlReportBuilder.php
Expand Up @@ -166,6 +166,9 @@ private function getFiles(): ArrayObject

if ($this->metricsCalculator->getTotalMutantsCount() !== 0) {
$resultsByPath = $this->retrieveResultsByPath();

Assert::minCount($resultsByPath, 1, 'There must be at least one result to build HTML report.');

$basePath = Path::getLongestCommonBasePath(array_keys($resultsByPath));

Assert::string($basePath, '$basePath must be a string');
Expand Down
6 changes: 2 additions & 4 deletions src/Mutation/FileMutationGenerator.php
Expand Up @@ -97,14 +97,12 @@ public function generate(
return;
}

$fileInfo = $trace->getSourceFileInfo();

$initialStatements = $this->parser->parse($fileInfo);
$initialStatements = $this->parser->parse($trace->getSourceFileInfo());

$mutationCollectorVisitor = new MutationCollectorVisitor(
new NodeMutationGenerator(
$mutators,
$fileInfo->getPathname(),
$trace->getRealPath(),
$initialStatements,
$trace,
$onlyCovered,
Expand Down
5 changes: 5 additions & 0 deletions tests/phpunit/Mutation/FileMutationGeneratorTest.php
Expand Up @@ -114,6 +114,11 @@ public function test_it_generates_mutations_for_a_given_file(): void
->method('getAllTestsForMutation')
->willReturn([])
;
$traceMock
->expects($this->once())
->method('getRealPath')
->willReturn(self::FIXTURES_DIR . '/Mutation/OneFile/OneFile.php')
;

$mutationGenerator = SingletonContainer::getContainer()->getFileMutationGenerator();

Expand Down