function SessionAuthenticationTest::assertSessionData
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php \Drupal\Tests\system\Functional\Session\SessionAuthenticationTest::assertSessionData()
- 8.9.x core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php \Drupal\Tests\system\Functional\Session\SessionAuthenticationTest::assertSessionData()
- 11.x core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php \Drupal\Tests\system\Functional\Session\SessionAuthenticationTest::assertSessionData()
Checks the session data returned by the session test routes.
@internal
Parameters
string $response: A response object containing the session values and the user ID.
string $expected: The expected session value.
1 call to SessionAuthenticationTest::assertSessionData()
- SessionAuthenticationTest::testBasicAuthSession in core/
modules/ system/ tests/ src/ Functional/ Session/ SessionAuthenticationTest.php - Tests if a session can be initiated through basic authentication.
File
-
core/
modules/ system/ tests/ src/ Functional/ Session/ SessionAuthenticationTest.php, line 111
Class
- SessionAuthenticationTest
- Tests if sessions are correctly handled when a user authenticates.
Namespace
Drupal\Tests\system\Functional\SessionCode
protected function assertSessionData(string $response, string $expected) : void {
$response = json_decode($response, TRUE);
$this->assertEquals([
'test_value' => $expected,
], $response['session'], 'The session data matches the expected value.');
// Check that we are logged in as the correct user.
$this->assertEquals($this->user
->id(), $response['user'], 'The correct user is logged in.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.