Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions system/Commands/Generators/TestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,17 @@ protected function buildPath(string $class): string
/**
* Returns test file path for the namespace.
*/
private function searchTestFilePath(string $namespace): ?string
private function searchTestFilePath(string $testNamespace): ?string
{
$bases = service('autoloader')->getNamespace($namespace);
/** @var list<non-empty-string> $testPaths */
$testPaths = service('autoloader')->getNamespace($testNamespace);

$base = null;

foreach ($bases as $candidate) {
if (str_contains($candidate, '/tests/')) {
$base = $candidate;

break;
foreach ($testPaths as $candidate) {
if (str_contains($candidate, DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR)) {
return $candidate;
}
}

return $base;
return null;
}
}
Loading