You are here

protected function SessionAuthenticationTest::assertSessionData in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php \Drupal\Tests\system\Functional\Session\SessionAuthenticationTest::assertSessionData()
  2. 9 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 109

Class

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

Namespace

Drupal\Tests\system\Functional\Session

Code

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