Skip to content

Commit

Permalink
minor #35178 [PhpUnitBridge][SymfonyTestsListenerTrait] Remove some u…
Browse files Browse the repository at this point in the history
…nneeded code (fancyweb)

This PR was merged into the 3.4 branch.

Discussion
----------

[PhpUnitBridge][SymfonyTestsListenerTrait] Remove some unneeded code

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Risky errors when there are no assertions are added before the test end listeners are called (ie, before the code in endTest is executed) so forcing beStrictAboutTestsThatDoNotTestAnything to false when there is a expectedDeprecation annotation is enough.

If the goal is to reset the value to the original value, then I think we should not do it since we basically "lie" to the next listeners. Let's assume that when a test expect a deprecation, it can have 0 assertions. Also this flag is not used anymore by PHPUnit after we reset it.

Ref #21786 btw

Commits
-------

fb48bbc [PhpUnitBridge][SymfonyTestsListenerTrait] Remove some unneeded code
  • Loading branch information
nicolas-grekas committed Jan 20, 2020
2 parents f889c11 + fb48bbc commit ff174df
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
Expand Up @@ -37,7 +37,6 @@ class SymfonyTestsListenerTrait
private $gatheredDeprecations = array();
private $previousErrorHandler;
private $testsWithWarnings;
private $reportUselessTests;
private $error;
private $runsInSeparateProcess = false;

Expand Down Expand Up @@ -198,10 +197,6 @@ public function addSkippedTest($test, \Exception $e, $time)
public function startTest($test)
{
if (-2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
if (null !== $test->getTestResultObject()) {
$this->reportUselessTests = $test->getTestResultObject()->isStrictAboutTestsThatDoNotTestAnything();
}

// This event is triggered before the test is re-run in isolation
if ($this->willBeIsolated($test)) {
$this->runsInSeparateProcess = tempnam(sys_get_temp_dir(), 'deprec');
Expand Down Expand Up @@ -267,11 +262,6 @@ public function endTest($test, $time)
$classGroups = $Test::getGroups($className);
$groups = $Test::getGroups($className, $test->getName(false));

if (null !== $this->reportUselessTests) {
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything($this->reportUselessTests);
$this->reportUselessTests = null;
}

if ($errored = null !== $this->error) {
$test->getTestResultObject()->addError($test, $this->error, 0);
$this->error = null;
Expand Down

0 comments on commit ff174df

Please sign in to comment.