8000 [PhpUnitBridge] Make ClockMock match namespaces that begin with Tests\\ · symfony/symfony@d40aafd · GitHub
[go: up one dir, main page]

Skip to content

Commit d40aafd

Browse files
committed
[PhpUnitBridge] Make ClockMock match namespaces that begin with Tests\\
1 parent 8ca614d commit d40aafd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Symfony/Bridge/PhpUnit/ClockMock.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ public static function register($class)
7373
{
7474
$self = get_called_class();
7575

76-
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
77-
if (strpos($class, '\\Tests\\')) {
78-
$ns = str_replace('\\Tests\\', '\\', $class);
79-
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
76+
$testNs = substr($class, 0, strrpos($class, '\\'));
77+
$mockedNs = array($testNs);
78+
if (false !== ($pos = strpos($testNs, '\\Tests\\'))) {
79+
$mockedNs[] = substr_replace($testNs, '\\', $pos, 7);
80+
} elseif (0 === strpos($testNs, 'Tests\\')) {
81+
$mockedNs[] = substr($testNs, 6);
8082
}
8183
foreach ($mockedNs as $ns) {
8284
if (function_exists($ns.'\time')) {

0 commit comments

Comments
 (0)
0