8000 testing for deprecations is not risky · symfony/symfony@864e459 · GitHub
[go: up one dir, main page]

Skip to content

Commit 864e459

Browse files
committed
testing for deprecations is not risky
1 parent e7a9f03 commit 864e459

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SymfonyTestsListenerTrait
3838
private $gatheredDeprecations = array();
3939
private $previousErrorHandler;
4040
private $testsWithWarnings;
41+
private $reportUselessTests;
4142

4243
/**
4344
* @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive)
@@ -172,6 +173,8 @@ public function addSkippedTest($test, \Exception $e, $time)
172173
public function startTest($test)
173174
{
174175
if (-2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
176+
$this->reportUselessTests = $test->getTestResultObject()->isStrictAboutTestsThatDoNotTestAnything();
177+
175178
if (class_exists('PHPUnit_Util_Blacklist', false)) {
176179
$Test = 'PHPUnit_Util_Test';
177180
$AssertionFailedError = 'PHPUnit_Framework_AssertionFailedError';
@@ -197,7 +200,10 @@ public function startTest($test)
197200
if (isset($annotations['method']['expectedDeprecation'])) {
198201
if (!in_array('legacy', $groups, true)) {
199202
$test->getTestResultObject()->addError($test, new $AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.'), 0);
203+
} else {
204+
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
200205
}
206+
201207
$this->expectedDeprecations = $annotations['method']['expectedDeprecation'];
202208
$this->previousErrorHandler = set_error_handler(array($this, 'handleError'));
203209
}
@@ -226,6 +232,11 @@ public function endTest($test, $time)
226232
$classGroups = $Test::getGroups($className);
227233
$groups = $Test::getGroups($className, $test->getName(false));
228234

235+
if (null !== $this->reportUselessTests) {
236+
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything($this->reportUselessTests);
237+
$this->reportUselessTests = null;
238+
}
239+
229240
if ($this->expectedDeprecations) {
230241
restore_error_handler();
231242

0 commit comments

Comments
 (0)
0