You are here

protected function DevelSwitchUserTest::assertNoSessionByUid in Devel 8

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/DevelSwitchUserTest.php \Drupal\Tests\devel\Functional\DevelSwitchUserTest::assertNoSessionByUid()
  2. 8.2 tests/src/Functional/DevelSwitchUserTest.php \Drupal\Tests\devel\Functional\DevelSwitchUserTest::assertNoSessionByUid()
  3. 4.x tests/src/Functional/DevelSwitchUserTest.php \Drupal\Tests\devel\Functional\DevelSwitchUserTest::assertNoSessionByUid()

Asserts that no session exists for a given uid.

Based off masquarade module.

Parameters

int $uid: The user ID to assert.

TODO find a cleaner way to do this check.

1 call to DevelSwitchUserTest::assertNoSessionByUid()
DevelSwitchUserTest::testSwitchUser in tests/src/Functional/DevelSwitchUserTest.php
Tests switch user.

File

tests/src/Functional/DevelSwitchUserTest.php, line 305

Class

DevelSwitchUserTest
Tests switch user.

Namespace

Drupal\Tests\devel\Functional

Code

protected function assertNoSessionByUid($uid) {
  $query = \Drupal::database()
    ->select('sessions');
  $query
    ->fields('sessions', [
    'uid',
  ]);
  $query
    ->condition('uid', $uid);
  $result = $query
    ->execute()
    ->fetchAll();
  $this
    ->assert(empty($result), "No session for uid {$uid} found.");
}