public function SessionTest::testSessionBag in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Session/SessionTest.php \Drupal\Tests\system\Functional\Session\SessionTest::testSessionBag()
- 9 core/modules/system/tests/src/Functional/Session/SessionTest.php \Drupal\Tests\system\Functional\Session\SessionTest::testSessionBag()
Tests session bag.
File
- core/
modules/ system/ tests/ src/ Functional/ Session/ SessionTest.php, line 326
Class
- SessionTest
- Drupal session handling tests.
Namespace
Drupal\Tests\system\Functional\SessionCode
public function testSessionBag() {
// Ensure the flag is absent to start with.
$this
->drupalGet('/session-test/has-bag-flag');
$this
->assertSessionCookie(FALSE);
$this
->assertSessionEmpty(TRUE);
$this
->assertSession()
->statusCodeEquals(200);
// Set the flag.
$this
->drupalGet('/session-test/set-bag-flag');
$this
->assertSessionCookie(TRUE);
$this
->assertSessionEmpty(TRUE);
$this
->assertSession()
->statusCodeEquals(200);
// Ensure the flag is set.
$this
->drupalGet('/session-test/has-bag-flag');
$this
->assertSessionCookie(TRUE);
$this
->assertSessionEmpty(FALSE);
$this
->assertSession()
->statusCodeEquals(200);
// Clear the flag.
$this
->drupalGet('/session-test/clear-bag-flag');
$this
->assertSessionCookie(FALSE);
$this
->assertSessionEmpty(FALSE);
$this
->assertSession()
->statusCodeEquals(200);
// Ensure the flag is absent again.
$this
->drupalGet('/session-test/has-bag-flag');
$this
->assertSessionCookie(FALSE);
$this
->assertSessionEmpty(TRUE);
$this
->assertSession()
->statusCodeEquals(200);
}