// Autoloading for tests, in case they sub-class one another (which
// generally they shouldn't).
if ( false !== strpos( $dir, '/phpunit/tests/' ) ) {
if ( '/test' === substr( $file_name, -9, 5 ) ) {
$file_name = substr( $file_name, 0, - 9 ) . '.php';
} else {
continue;
}
}
The problem is that $file_name is permanently modified, for all future iterations of the loop. So if multiple test directories are registered for the same prefix, any classes in the latter directories will not be loaded. Specifically, the $dir will match the outer condition for all of the directories, but because the $file_name will have been modified on the first iteration, the inner condition will not be met, so the latter directories will be skipped by the continue statement.
I'm actually not entirely sure what the purpose of the else in the inner condition is anyway.
This section causes the issue:
The problem is that
$file_name
is permanently modified, for all future iterations of the loop. So if multiple test directories are registered for the same prefix, any classes in the latter directories will not be loaded. Specifically, the$dir
will match the outer condition for all of the directories, but because the$file_name
will have been modified on the first iteration, the inner condition will not be met, so the latter directories will be skipped by thecontinue
statement.I'm actually not entirely sure what the purpose of the
else
in the inner condition is anyway.