You are here

public function SessionLimitPreventTestCase::testSessionLimitRoles in Session Limit 8

Same name in this branch
  1. 8 tests/session_limit.test \SessionLimitPreventTestCase::testSessionLimitRoles()
  2. 8 tests/SessionLimitPreventTestCase.php \Drupal\session_limit\SessionLimitPreventTestCase::testSessionLimitRoles()
Same name and namespace in other branches
  1. 2.x tests/SessionLimitPreventTestCase.php \Drupal\session_limit\SessionLimitPreventTestCase::testSessionLimitRoles()

Checks that the session limit is returned correctly by a role.

File

tests/SessionLimitPreventTestCase.php, line 53

Class

SessionLimitPreventTestCase
Session limit functionality when behaviour is to prevent login at limit.

Namespace

Drupal\session_limit

Code

public function testSessionLimitRoles() {

  // Create a test user.
  $user = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $roles = $this
    ->sessionLimitMakeRoles($user);

  // Set the session limits for the roles.
  // @FIXME
  // // @FIXME
  // // The correct configuration object could not be determined. You'll need to
  // // rewrite this call manually.
  // variable_set('session_limit_rid_' . $roles[0]->rid, 2);
  // @FIXME
  // // @FIXME
  // // The correct configuration object could not be determined. You'll need to
  // // rewrite this call manually.
  // variable_set('session_limit_rid_' . $roles[1]->rid, 4);
  // @FIXME
  // // @FIXME
  // // The correct configuration object could not be determined. You'll need to
  // // rewrite this call manually.
  // variable_set('session_limit_rid_' . $roles[2]->rid, 3);
  // Set the default session limit.
  \Drupal::configFactory()
    ->getEditable('session_limit.settings')
    ->set('session_limit_max', 1)
    ->save();

  // Check if the user has access to 4 sessions.
  $this
    ->assertSessionPrevent(4, $user);
}