function DrupalTestCaseTrait::checkErrorHandlerOnTearDown

Checks the test error handler after test execution.

Attributes

#[After]

File

core/tests/Drupal/Tests/DrupalTestCaseTrait.php, line 21

Class

DrupalTestCaseTrait
Provides methods common across all Drupal abstract base test classes.

Namespace

Drupal\Tests

Code

public function checkErrorHandlerOnTearDown() : void {
  // We expect that the current error handler is the one set during the
  // PHPUnit bootstrap. If not, the error handler was changed during the test
  // execution but not properly restored during ::tearDown().
  if (DeprecationHandler::isEnabled() && !get_error_handler() instanceof BootstrapErrorHandler) {
    throw new \RuntimeException(sprintf('%s registered its own error handler without restoring the previous one before or during tear down. This can cause unpredictable test results. Ensure the test cleans up after itself.', $this->name()));
  }
}

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