diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index 2d6573f5..1d4df194 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -31,6 +31,11 @@ final class TestRepository */ private array $uses = []; + /** + * @var array + */ + private array $isDirectory = []; + /** * @var array */ @@ -156,7 +161,9 @@ final class TestRepository foreach ($this->uses as $path => $uses) { [$classOrTraits, $groups, $hooks] = $uses; - if ((! is_dir($path) && $testCase->filename === $path) || (is_dir($path) && $startsWith($testCase->filename, $path))) { + $isDirectory = $this->isDirectory[$path] ??= is_dir($path); + + if ((! $isDirectory && $testCase->filename === $path) || ($isDirectory && $startsWith($testCase->filename, $path))) { foreach ($classOrTraits as $class) { /** @var string $class */ if (class_exists($class)) {