feature #18726 [PhpUnitBridge] Make ClockMock match namespaces that begin with Tests\\ (teohhanhui)

This PR was submitted for the 2.8 branch but it was merged into the 3.2-dev branch instead (closes #18726).

Discussion
----------

[PhpUnitBridge] Make ClockMock match namespaces that begin with Tests\\

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes?
| New feature?  | no
| BC breaks?    | no?
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | symfony/symfony-docs#6546

See symfony/symfony-standard#969

Commits
-------

2630c13 [PhpUnitBridge] Make ClockMock match namespaces that begin with Tests\\
This commit is contained in:
Nicolas Grekas 2016-05-30 09:55:31 +02:00
commit b59664bc42

View File

@ -77,6 +77,8 @@ class ClockMock
if (0 < strpos($class, '\\Tests\\')) {
$ns = str_replace('\\Tests\\', '\\', $class);
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
} elseif (0 === strpos($class, 'Tests\\')) {
$mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6);
}
foreach ($mockedNs as $ns) {
if (function_exists($ns.'\time')) {