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

Skip to content

Commit d264ac7

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

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Symfony/Bridge/PhpUnit/ClockMock.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ public static function register($class)
7474
$self = get_called_class();
7575

7676
$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, '\\'));
77+
$count = 0;
78+
$ns = preg_replace('/(^|\\\\)Tests\\\\/', '$1', $mockedNs[0], 1, $count);
79+
if (1 === $count) {
80+
$mockedNs[] = $ns;
8081
}
8182
foreach ($mockedNs as $ns) {
8283
if (function_exists($ns.'\time')) {

0 commit comments

Comments
 (0)
0