function KernelTestBaseTest::testSessionOnRequest
Same name in other branches
- 10 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSessionOnRequest()
Tests that a usable session is on the request.
@covers ::bootKernel
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestBaseTest.php, line 239
Class
- KernelTestBaseTest
- @coversDefaultClass \Drupal\KernelTests\KernelTestBase
Namespace
Drupal\KernelTestsCode
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'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.