diff --git a/system/Commands/Generators/TestGenerator.php b/system/Commands/Generators/TestGenerator.php index 7ab6859ed9a9..d37864d76efc 100644 --- a/system/Commands/Generators/TestGenerator.php +++ b/system/Commands/Generators/TestGenerator.php @@ -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 $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; } } diff --git a/user_guide_src/source/changelogs/v4.6.2.rst b/user_guide_src/source/changelogs/v4.6.2.rst index 3e45e3c2409e..7ebf81108938 100644 --- a/user_guide_src/source/changelogs/v4.6.2.rst +++ b/user_guide_src/source/changelogs/v4.6.2.rst @@ -36,6 +36,7 @@ Bugs Fixed ********** - **Cache:** Fixed a bug where a corrupted or unreadable cache file could cause an unhandled exception in ``FileHandler::getItem()``. +- **Commands:** Fixed a bug in ``make:test`` where it would always error on Windows. - **CURLRequest:** Fixed a bug where intermediate HTTP responses were not properly removed from the response chain in certain scenarios, causing incorrect status codes and headers to be returned instead of the final response. - **Database:** Fixed a bug where ``when()`` and ``whenNot()`` in ``ConditionalTrait`` incorrectly evaluated certain falsy values (such as ``[]``, ``0``, ``0.0``, and ``'0'``) as truthy, causing callbacks to be executed unexpectedly. These methods now cast the condition to a boolean using ``(bool)`` to ensure consistent behavior with PHP's native truthiness. - **Database:** Fixed encapsulation violation in ``BasePreparedQuery`` when accessing ``BaseConnection::transStatus`` protected property.