function SessionAuthenticationTest::testBasicAuthSession
Same name in other branches
- 8.9.x core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php \Drupal\Tests\system\Functional\Session\SessionAuthenticationTest::testBasicAuthSession()
- 10 core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php \Drupal\Tests\system\Functional\Session\SessionAuthenticationTest::testBasicAuthSession()
- 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 86
Class
- SessionAuthenticationTest
- Tests if sessions are correctly handled when a user authenticates.
Namespace
Drupal\Tests\system\Functional\SessionCode
public function testBasicAuthSession() {
// 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.