Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Aug 11, 2022
1 parent 57ae9ed commit 4787312
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/Runner/StandardTestSuiteLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,12 @@ public function load(string $suiteClassFile): ReflectionClass
}

if (!class_exists($suiteClassName, false)) {
// Perhaps this file defines a class inside a namespace? Let's check...
$offset = 0 - strlen($suiteClassName);

foreach ($loadedClasses as $loadedClass) {
// Detect modern namespace (eg './tests/Foo/Bar/WhizBangTest.php' <=> 'Foo\Bar\WhizBangTest')
if (stripos(substr($loadedClass, $offset - 1), '\\' . $suiteClassName) === 0) {
$suiteClassName = $loadedClass;

break;
}

// Detect old-school namespace (eg 'tests/Foo/Bar/WhizBangTest.php' <=> 'Foo_Bar_WhizBangTest'; #5020)
if (stripos(substr($loadedClass, $offset - 1), '_' . $suiteClassName) === 0) {
// @see https://github.com/sebastianbergmann/phpunit/issues/5020
if (stripos(substr($loadedClass, $offset - 1), '\\' . $suiteClassName) === 0 ||
stripos(substr($loadedClass, $offset - 1), '_' . $suiteClassName) === 0) {
$suiteClassName = $loadedClass;

break;
Expand Down

0 comments on commit 4787312

Please sign in to comment.