Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d253136

Browse files
bug #16455 [Bridge\PhpUnit] Fix clock-mock registration (nicolas-grekas)
This PR was merged into the 2.8 branch. Discussion ---------- [Bridge\PhpUnit] Fix clock-mock registration | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Once a method has been executed, PHP ignores any new function that could be injected in the namespace afterwards (HHVM does not ignore them btw). Which means we have to inject clock-mocking functions into all clock-mocked namespaces before any actual implementation is used in that namespace. This PR does it. Commits ------- 0a6a10a [Bridge\PhpUnit] Fix clock-mock registration
2 parents 9e39329 + 0a6a10a commit d253136

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
5656
}
5757
}
5858
}
59+
foreach ($suite->tests() as $test) {
60+
if ($test instanceof \PHPUnit_Framework_TestSuite && in_array('time-sensitive', \PHPUnit_Util_Test::getGroups($test->getName()), true)) {
61+
ClockMock::register($test->getName());
62+
}
63+
}
5964
} elseif (2 === $this->state) {
6065
$skipped = array();
6166
foreach ($suite->tests() as $test) {

0 commit comments

Comments
 (0)