summaryrefslogtreecommitdiffstatshomepage
path: root/core/tests/Drupal/Tests/BrowserTestBase.php
diff options
context:
space:
mode:
authorLee Rowlands <lee.rowlands@previousnext.com.au>2023-12-28 08:03:14 +1000
committerLee Rowlands <lee.rowlands@previousnext.com.au>2023-12-28 08:03:14 +1000
commitfbee2baaab8fb8f8be29462e4798b51e1fe758d4 (patch)
tree976ab6bc1996f933d735884dfc83298074745fb4 /core/tests/Drupal/Tests/BrowserTestBase.php
parentc980ece64ec31e8ae96a3c73d450472dff69b531 (diff)
downloaddrupal-fbee2baaab8fb8f8be29462e4798b51e1fe758d4.tar.gz
drupal-fbee2baaab8fb8f8be29462e4798b51e1fe758d4.zip
Issue #2484991 by znerol, voleger, andypost, dww, anmolgoyal74, markdorison, ankithashetty, larowlan, daffie, alexpott: Add the session to the request in KernelTestBase, BrowserTestBase, and drush
Diffstat (limited to 'core/tests/Drupal/Tests/BrowserTestBase.php')
-rw-r--r--core/tests/Drupal/Tests/BrowserTestBase.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index 38b41f4163d..082292646ee 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -24,6 +24,7 @@ use Drupal\TestTools\TestVarDumper;
use GuzzleHttp\Cookie\CookieJar;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
+use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
use Symfony\Component\VarDumper\VarDumper;
/**
@@ -446,6 +447,19 @@ abstract class BrowserTestBase extends TestCase {
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();