Skip to content

Commit 356d444

Browse files
realFlowControlsebastianbergmann
authored andcommitted
allow for case insensitive class names #4498
1 parent 9686399 commit 356d444

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

src/Runner/StandardTestSuiteLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use function class_exists;
1616
use function get_declared_classes;
1717
use function sprintf;
18-
use function str_replace;
18+
use function stripos;
1919
use function strlen;
2020
use function substr;
2121
use PHPUnit\Framework\TestCase;
@@ -52,11 +52,11 @@ public function load(string $suiteClassFile): ReflectionClass
5252
}
5353

5454
if (!class_exists($suiteClassName, false)) {
55+
// this block will handle namespaced classes
5556
$offset = 0 - strlen($suiteClassName);
5657

5758
foreach ($loadedClasses as $loadedClass) {
58-
if (substr($loadedClass, $offset) === $suiteClassName &&
59-
basename(str_replace('\\', '/', $loadedClass)) === $suiteClassName) {
59+
if (stripos(substr($loadedClass, $offset - 1), '\\' . $suiteClassName) === 0) {
6060
$suiteClassName = $loadedClass;
6161

6262
break;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/4498
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/4498/Issue4498Test.php';
8+
9+
require __DIR__ . '/../../../bootstrap.php';
10+
11+
PHPUnit\TextUI\Command::main();
12+
--EXPECTF--
13+
PHPUnit %s by Sebastian Bergmann and contributors.
14+
15+
. 1 / 1 (100%)
16+
17+
Time: %s, Memory: %s
18+
19+
OK (1 test, 1 assertion)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture;
11+
12+
use PHPUnit\Framework\TestCase;
13+
14+
class issue4498test extends TestCase
15+
{
16+
public function testFoo(): void
17+
{
18+
$this->assertTrue(true);
19+
}
20+
}

0 commit comments

Comments
 (0)