trait DrupalTestCaseTrait
Provides methods common across all Drupal abstract base test classes.
This trait is meant to be used only by test classes.
Hierarchy
- trait \Drupal\Tests\DrupalTestCaseTrait
2 files declare their use of DrupalTestCaseTrait
- BuildTestBase.php in core/
tests/ Drupal/ BuildTests/ Framework/ BuildTestBase.php - KernelTestBase.php in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php
File
-
core/
tests/ Drupal/ Tests/ DrupalTestCaseTrait.php, line 16
Namespace
Drupal\TestsView source
trait DrupalTestCaseTrait {
/**
* Checks the test error handler after test execution.
*/
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.