WordPoints / dev-lib

Developer tools for WordPoints projects
MIT License
4 stars 0 forks source link

phpunit: autoloader sometimes fails to load PHPUnit test cases #177

Closed JDGrimes closed 8 years ago

JDGrimes commented 8 years ago

This section causes the issue:

                // 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.