function SessionTest::testSessionBag

Same name and namespace in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Session/SessionTest.php \Drupal\Tests\system\Functional\Session\SessionTest::testSessionBag()
  2. 10 core/modules/system/tests/src/Functional/Session/SessionTest.php \Drupal\Tests\system\Functional\Session\SessionTest::testSessionBag()
  3. 11.x 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 329

Class

SessionTest
Drupal session handling tests.

Namespace

Drupal\Tests\system\Functional\Session

Code

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.