summaryrefslogtreecommitdiffstatshomepage
path: root/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.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/FunctionalTests/BrowserTestBaseTest.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/FunctionalTests/BrowserTestBaseTest.php')
-rw-r--r--core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index e83b425dc42c..f0035f4b1f4e 100644
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -11,6 +11,7 @@ use Drupal\Tests\StreamCapturer;
use Drupal\Tests\Traits\Core\CronRunTrait;
use Drupal\user\Entity\Role;
use PHPUnit\Framework\ExpectationFailedException;
+use Symfony\Component\HttpFoundation\Request;
/**
* Tests BrowserTestBase functionality.
@@ -522,6 +523,30 @@ class BrowserTestBaseTest extends BrowserTestBase {
}
/**
+ * Tests that a usable session is on the request in test-runner.
+ */
+ public function testSessionOnRequest(): void {
+ /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
+ $session = $this->container->get('request_stack')->getSession();
+
+ $session->set('some-val', 'do-not-cleanup');
+ $this->assertEquals('do-not-cleanup', $session->get('some-val'));
+
+ $session->set('some-other-val', 'do-cleanup');
+ $this->assertEquals('do-cleanup', $session->remove('some-other-val'));
+ }
+
+ /**
+ * Tests deprecation of modified request stack lacking a session.
+ *
+ * @group legacy
+ */
+ public function testDeprecatedSessionMissing(): void {
+ $this->expectDeprecation('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');
+ $this->container->get('request_stack')->push(Request::create('/'));
+ }
+
+ /**
* Tests that deprecation headers do not get duplicated.
*
* @group legacy