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

ProxyTrace should check for tests locations #1494

Merged
merged 3 commits into from
Mar 1, 2021
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: 4 additions & 0 deletions src/TestFramework/Coverage/ProxyTrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public function getTests(): ?TestLocations

public function getAllTestsForMutation(NodeLineRangeData $lineRange, bool $isOnFunctionSignature): iterable
{
if ($this->lazyTestLocations === null) {
return [];
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NodeMutationGenerator does not check if there are tests, just asks for them. It is not their call to know the details, so we're doing it here.


return $this->getTestLocator()->getAllTestsForMutation($lineRange, $isOnFunctionSignature);
}

Expand Down
9 changes: 9 additions & 0 deletions tests/phpunit/TestFramework/Coverage/ProxyTraceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ public function test_it_returns_null_for_no_tests(): void
$this->assertNull($trace->getTests());
}

public function test_it_returns_empty_iterable_for_no_tests(): void
{
$fileInfoMock = $this->createMock(SplFileInfo::class);

$trace = new ProxyTrace($fileInfoMock, null);

$this->assertCount(0, $trace->getAllTestsForMutation(new NodeLineRangeData(1, 2), false));
}

public function test_it_exposes_its_test_locations(): void
{
$fileInfoMock = $this->createMock(SplFileInfo::class);
Expand Down