Skip to content

Commit

Permalink
bug #20544 [PhpUnitBridge] Fix time-sensitive tests that use data pro…
Browse files Browse the repository at this point in the history
…viders (julienfalque)

This PR was merged into the 2.8 branch.

Discussion
----------

[PhpUnitBridge] Fix time-sensitive tests that use data providers

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

When a test uses a data provider, the `@group time-sensitive` annotation does not work if it is set on the method because the test name includes the data provider name by default. This was fixed in master by c344203 but not in 2.8, 3.0 and 3.1.

Commits
-------

f376cde Fix time-sensitive tests that use data providers
  • Loading branch information
nicolas-grekas committed Nov 17, 2016
2 parents 7487ccb + f376cde commit 6095835
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
Expand Up @@ -134,7 +134,7 @@ public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $ti
public function startTest(\PHPUnit_Framework_Test $test)
{
if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) {
$groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName());
$groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false));

if (in_array('time-sensitive', $groups, true)) {
ClockMock::register(get_class($test));
Expand All @@ -146,7 +146,7 @@ public function startTest(\PHPUnit_Framework_Test $test)
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) {
$groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName());
$groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false));

if (in_array('time-sensitive', $groups, true)) {
ClockMock::withClockMock(false);
Expand Down

0 comments on commit 6095835

Please sign in to comment.