Skip to content

Commit 53344d0

Browse files
minor symfony#21180 [PhpUnitBridge] silence warnings on PHPUnit 4.8 (xabbuh)
This PR was merged into the 3.3-dev branch. Discussion ---------- [PhpUnitBridge] silence warnings on PHPUnit 4.8 | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | The concept of warnings is only available since PHPUnit 5. We can later think about whether we need this for PHPUnit 4.8 to or if we should rather aim to drop PHPUnit 4.8 support in 4.0. For now, this change will make the test suite green again. Commits ------- 2c3de10 silence warnings on PHPUnit 4.8
2 parents 66f7126 + 2c3de10 commit 53344d0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,19 @@ public function endTest(\PHPUnit_Framework_Test $test, $time)
212212
}
213213

214214
if ($test instanceof \PHPUnit_Framework_TestCase && 0 === strpos($test->getName(), 'testLegacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $groups, true)) {
215-
$test->getTestResultObject()->addWarning($test, new \PHPUnit_Framework_Warning('Using the "testLegacy" prefix to mark tests as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time);
215+
$result = $test->getTestResultObject();
216+
217+
if (method_exists($result, 'addWarning')) {
218+
$result->addWarning($test, new \PHPUnit_Framework_Warning('Using the "testLegacy" prefix to mark tests as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time);
219+
}
216220
}
217221

218222
if ($test instanceof \PHPUnit_Framework_TestCase && strpos($className, '\Legacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $classGroups, true)) {
219-
$test->getTestResultObject()->addWarning($test, new \PHPUnit_Framework_Warning('Using the "Legacy" prefix to mark all tests of a class as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time);
223+
$result = $test->getTestResultObject();
224+
225+
if (method_exists($result, 'addWarning')) {
226+
$result->addWarning($test, new \PHPUnit_Framework_Warning('Using the "Legacy" prefix to mark all tests of a class as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time);
227+
}
220228
}
221229
}
222230

0 commit comments

Comments
 (0)