@@ -107,17 +107,9 @@ private static function getTestClasses(): array
107107
108108 $ testClasses = array_map (
109109 static function (SplFileInfo $ file ) use ($ directory ): string {
110- $ relativePath = substr_replace (
111- $ file ->getPathname (),
112- '' ,
113- 0 ,
114- strlen ($ directory ),
115- );
116- $ relativePath = substr_replace (
117- $ relativePath ,
118- '' ,
119- strlen ($ relativePath ) - strlen (DIRECTORY_SEPARATOR . $ file ->getBasename ()),
120- );
110+ $ relativePath = substr ($ file ->getPathname (), strlen ($ directory ));
111+ $ separatorPos = strrpos ($ relativePath , DIRECTORY_SEPARATOR );
112+ $ relativePath = $ separatorPos === false ? '' : substr ($ relativePath , 0 , $ separatorPos );
121113
122114 return sprintf (
123115 'CodeIgniter \\%s%s%s ' ,
@@ -128,17 +120,15 @@ static function (SplFileInfo $file) use ($directory): string {
128120 },
129121 array_filter (
130122 iterator_to_array ($ iterator , false ),
123+ // Filename-based heuristic: avoids the is_subclass_of() cold-autoload issue
124+ // by only considering files that end with "Test.php" or "TestCase.php".
131125 static fn (SplFileInfo $ file ): bool => $ file ->isFile ()
126+ && (str_ends_with ($ file ->getBasename (), 'Test.php ' ) || str_ends_with ($ file ->getBasename (), 'TestCase.php ' ))
132127 && ! str_contains ($ file ->getPathname (), DIRECTORY_SEPARATOR . 'fixtures ' . DIRECTORY_SEPARATOR )
133128 && ! str_contains ($ file ->getPathname (), DIRECTORY_SEPARATOR . 'Views ' . DIRECTORY_SEPARATOR ),
134129 ),
135130 );
136131
137- $ testClasses = array_filter (
138- $ testClasses ,
139- static fn (string $ class ): bool => is_subclass_of ($ class , TestCase::class),
140- );
141-
142132 sort ($ testClasses );
143133
144134 self ::$ testClasses = $ testClasses ;
0 commit comments