function BrowserTestBase::tearDown

Same name in other branches
  1. 9 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::tearDown()
  2. 8.9.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::tearDown()
  3. 11.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\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 449

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\Tests

Code

protected function tearDown() : void {
    parent::tearDown();
    if ($this->container) {
        // Cleanup mock session started in DrupalKernel::preHandle().
        try {
            
            /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
            $session = $this->container
                ->get('request_stack')
                ->getSession();
            $session->clear();
            $session->save();
        } catch (SessionNotFoundException) {
            @trigger_error('Pushing requests without a session onto the request_stack is deprecated in drupal:10.3.0 and an error will be thrown from drupal:11.0.0. See https://www.drupal.org/node/3337193', E_USER_DEPRECATED);
        }
    }
    // Destroy the testing kernel.
    if (isset($this->kernel)) {
        $this->cleanupEnvironment();
        $this->kernel
            ->shutdown();
    }
    // Ensure that internal logged in variable is reset.
    $this->loggedInUser = FALSE;
    if ($this->mink) {
        $this->mink
            ->stopSessions();
    }
    // 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.