function BrowserTestBase::tearDown
3 calls to BrowserTestBase::tearDown()
- MigrateUpgradeTestBase::tearDown in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ MigrateUpgradeTestBase.php - ShutdownFunctionsTest::tearDown in core/
modules/ system/ tests/ src/ Functional/ System/ ShutdownFunctionsTest.php - WebDriverTestBase::tearDown in core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php
3 methods override BrowserTestBase::tearDown()
- MigrateUpgradeTestBase::tearDown in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ MigrateUpgradeTestBase.php - ShutdownFunctionsTest::tearDown in core/
modules/ system/ tests/ src/ Functional/ System/ ShutdownFunctionsTest.php - WebDriverTestBase::tearDown in core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php
File
-
core/
tests/ Drupal/ Tests/ BrowserTestBase.php, line 411
Class
- BrowserTestBase
- Provides a test case for functional Drupal tests.
Namespace
Drupal\TestsCode
protected function tearDown() : void {
// Close any mink sessions as early as possible to free a new browser
// session up for the next test method or test.
if ($this->mink) {
$this->mink
->stopSessions();
}
parent::tearDown();
if ($this->container) {
// Cleanup mock session started in DrupalKernel::preHandle().
/** @var \Symfony\Component\HttpFoundation\Session\Session $session */
$session = $this->container
->get('request_stack')
->getSession();
$session->clear();
$session->save();
// If cron is running because Automated Cron started it at the end of a
// test request, wait for it to complete.
if ($this->container
->has('module_handler') && $this->container
->has('lock')) {
$module_handler = $this->container
->get('module_handler');
assert($module_handler instanceof ModuleHandlerInterface);
$lock = $this->container
->get('lock');
assert($lock instanceof LockBackendInterface);
if ($module_handler->moduleExists('automated_cron') && !$lock->lockMayBeAvailable('cron')) {
// Use the timeout that is used for acquiring the lock as a delay.
/* @see \Drupal\Core\Cron::run() */
$lock->wait('cron', 900.0);
}
}
}
// Destroy the testing kernel.
if (isset($this->kernel)) {
$this->cleanupEnvironment();
$this->kernel
->shutdown();
}
// Ensure that internal logged in variable is reset.
$this->loggedInUser = FALSE;
// Restore original shutdown callbacks.
if (function_exists('drupal_register_shutdown_function')) {
$callbacks =& drupal_register_shutdown_function();
$callbacks = $this->originalShutdownCallbacks;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.