Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0f4bc14

Browse filesBrowse files
committed
feature #21786 [PhpUnitBridge] testing for deprecations is not risky (xabbuh)
This PR was merged into the 3.3-dev branch. Discussion ---------- [PhpUnitBridge] testing for deprecations is not risky | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 044cc8f testing for deprecations is not risky
2 parents 9e4f82e + 044cc8f commit 0f4bc14
Copy full SHA for 0f4bc14

File tree

1 file changed

+13
-0
lines changed
Filter options

1 file changed

+13
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
+13Lines changed: 13 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,10 @@ 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+
if (null !== $test->getTestResultObject()) {
177+
$this->reportUselessTests = $test->getTestResultObject()->isStrictAboutTestsThatDoNotTestAnything();
178+
}
179+
175180
if (class_exists('PHPUnit_Util_Blacklist', false)) {
176181
$Test = 'PHPUnit_Util_Test';
177182
$AssertionFailedError = 'PHPUnit_Framework_AssertionFailedError';
@@ -197,7 +202,10 @@ public function startTest($test)
197202
if (isset($annotations['method']['expectedDeprecation'])) {
198203
if (!in_array('legacy', $groups, true)) {
199204
$test->getTestResultObject()->addError($test, new $AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.'), 0);
205+
} else {
206+
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
200207
}
208+
201209
$this->expectedDeprecations = $annotations['method']['expectedDeprecation'];
202210
$this->previousErrorHandler = set_error_handler(array($this, 'handleError'));
203211
}
@@ -226,6 +234,11 @@ public function endTest($test, $time)
226234
$classGroups = $Test::getGroups($className);
227235
$groups = $Test::getGroups($className, $test->getName(false));
228236

237+
if (null !== $this->reportUselessTests) {
238+
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything($this->reportUselessTests);
239+
$this->reportUselessTests = null;
240+
}
241+
229242
if ($this->expectedDeprecations) {
230243
restore_error_handler();
231244

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.