function SessionAuthenticationTest::testBasicAuthSession

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php \Drupal\Tests\system\Functional\Session\SessionAuthenticationTest::testBasicAuthSession()
  2. 8.9.x core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php \Drupal\Tests\system\Functional\Session\SessionAuthenticationTest::testBasicAuthSession()
  3. 11.x core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php \Drupal\Tests\system\Functional\Session\SessionAuthenticationTest::testBasicAuthSession()

Tests if a session can be initiated through basic authentication.

File

core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php, line 88

Class

SessionAuthenticationTest
Tests if sessions are correctly handled when a user authenticates.

Namespace

Drupal\Tests\system\Functional\Session

Code

public function testBasicAuthSession() : void {
  // Set a session value on a request through basic auth.
  $test_value = 'alpaca';
  $response = $this->basicAuthGet('session-test/set-session/' . $test_value, $this->user
    ->getAccountName(), $this->user->pass_raw);
  $this->assertSessionData($response, $test_value);
  $this->assertSession()
    ->statusCodeEquals(200);
  // Test that on a subsequent request the session value is still present.
  $response = $this->basicAuthGet('session-test/get-session', $this->user
    ->getAccountName(), $this->user->pass_raw);
  $this->assertSessionData($response, $test_value);
  $this->assertSession()
    ->statusCodeEquals(200);
}

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