You are here

protected function UiHelperTrait::drupalUserIsLoggedIn in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalUserIsLoggedIn()
  2. 10 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalUserIsLoggedIn()

Returns whether a given user account is logged in.

Parameters

\Drupal\Core\Session\AccountInterface $account: The user account object to check.

Return value

bool Return TRUE if the user is logged in, FALSE otherwise.

3 calls to UiHelperTrait::drupalUserIsLoggedIn()
DemoUmamiProfileTest::drupalLoginWithPassword in core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php
Logs in a user using the Mink controlled browser using a password.
UiHelperTrait::drupalLogin in core/tests/Drupal/Tests/UiHelperTrait.php
Logs in a user using the Mink controlled browser.
UserHelpersTest::testDrupalUserIsLoggedIn in core/tests/Drupal/FunctionalTests/UserHelpersTest.php
Tests BrowserTestBase::drupalUserIsLoggedIn().

File

core/tests/Drupal/Tests/UiHelperTrait.php, line 453

Class

UiHelperTrait
Provides UI helper methods.

Namespace

Drupal\Tests

Code

protected function drupalUserIsLoggedIn(AccountInterface $account) {
  $logged_in = FALSE;
  if (isset($account->sessionId)) {
    $session_handler = \Drupal::service('session_handler.storage');
    $logged_in = (bool) $session_handler
      ->read($account->sessionId);
  }
  return $logged_in;
}