public function SessionAuthenticationTest::testBasicAuthSession in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Session/SessionAuthenticationTest.php \Drupal\system\Tests\Session\SessionAuthenticationTest::testBasicAuthSession()
Tests if a session can be initiated through basic authentication.
File
- core/
modules/ system/ src/ Tests/ Session/ SessionAuthenticationTest.php, line 84 - Contains \Drupal\system\Tests\Session\SessionAuthenticationTest.
Class
- SessionAuthenticationTest
- Tests if sessions are correctly handled when a user authenticates.
Namespace
Drupal\system\Tests\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
->getUsername(), $this->user->pass_raw);
$this
->assertSessionData($response, $test_value);
$this
->assertResponse(200, 'The request to set a session value was successful.');
// Test that on a subsequent request the session value is still present.
$response = $this
->basicAuthGet('session-test/get-session', $this->user
->getUsername(), $this->user->pass_raw);
$this
->assertSessionData($response, $test_value);
$this
->assertResponse(200, 'The request to get a session value was successful.');
}