function DrupalStandardsListenerTrait::doEndTest

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php \Drupal\Tests\Listeners\DrupalStandardsListenerTrait::doEndTest()

Reacts to the end of a test.

We must mark this method as belonging to the special legacy group because it might trigger an E_USER_DEPRECATED error during coverage annotation validation. The legacy group allows symfony/phpunit-bridge to keep the deprecation notice as a warning instead of an error, which would fail the test.

@group legacy

Parameters

\PHPUnit\Framework\Test $test: The test object that has ended its test run.

float $time: The time the test took.

See also

http://symfony.com/doc/current/components/phpunit_bridge.html#mark-test…

1 call to DrupalStandardsListenerTrait::doEndTest()
DrupalStandardsListenerTrait::standardsEndTest in core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php
Reacts to the end of a test.

File

core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php, line 196

Class

DrupalStandardsListenerTrait
Listens for PHPUnit tests and fails those with invalid coverage annotations.

Namespace

Drupal\Tests\Listeners

Code

private function doEndTest($test, $time) {
    // \PHPUnit\Framework\Test does not have any useful methods of its own for
    // our purpose, so we have to distinguish between the different known
    // subclasses.
    if ($test instanceof TestCase) {
        // Change the error handler to ensure deprecation messages are not
        // triggered.
        set_error_handler([
            $this,
            'errorHandler',
        ]);
        $this->checkValidCoversForTest($test);
        restore_error_handler();
    }
    elseif ($this->isTestSuite($test)) {
        foreach ($test->getGroupDetails() as $tests) {
            foreach ($tests as $test) {
                $this->doEndTest($test, $time);
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.