The getFilenames method now respects only calls.

This commit is contained in:
luke
2021-08-13 11:07:52 +01:00
parent b6c06e8c30
commit 5c84b0c6d3
3 changed files with 35 additions and 5 deletions

View File

@ -45,13 +45,17 @@ final class TestRepository
}
/**
* Returns the filename of each test that should be run in the suite.
*
* @return array<int, string>
*/
public function getFilenames(): array
{
$testsWithOnly = $this->testsUsingOnly();
return array_values(array_map(function (TestCaseFactory $factory): string {
return $factory->filename;
}, $this->state));
}, count($testsWithOnly) > 0 ? $testsWithOnly : $this->state));
}
/**
@ -95,9 +99,7 @@ final class TestRepository
}
}
$onlyState = array_filter($this->state, function ($testFactory): bool {
return $testFactory->only;
});
$onlyState = $this->testsUsingOnly();
$state = count($onlyState) > 0 ? $onlyState : $this->state;
@ -110,6 +112,18 @@ final class TestRepository
}
}
/**
* Return all tests that have called the only method.
*
* @return array<TestCaseFactory>
*/
private function testsUsingOnly(): array
{
return array_filter($this->state, function ($testFactory): bool {
return $testFactory->only;
});
}
/**
* Uses the given `$testCaseClass` on the given `$paths`.
*