public function SessionLimitLogoutTestCase::testSessionLimitUserMaxPrecedence in Session Limit 8
Same name in this branch
- 8 tests/session_limit.test \SessionLimitLogoutTestCase::testSessionLimitUserMaxPrecedence()
- 8 tests/SessionLimitLogoutTestCase.php \Drupal\session_limit\SessionLimitLogoutTestCase::testSessionLimitUserMaxPrecedence()
Same name and namespace in other branches
- 2.x tests/SessionLimitLogoutTestCase.php \Drupal\session_limit\SessionLimitLogoutTestCase::testSessionLimitUserMaxPrecedence()
Check that user override takes precedence over default and role regardless of max.
File
- tests/SessionLimitLogoutTestCase.php, line 129 
Class
- SessionLimitLogoutTestCase
- Session limit functions when expected behaviour is to logout oldest session.
Namespace
Drupal\session_limitCode
public function testSessionLimitUserMaxPrecedence() {
  // Create a test user.
  $user = $this
    ->drupalCreateUser();
  $roles = $this
    ->sessionLimitMakeRoles($user);
  // Add a personal session limit.
  // @FIXME
  // user_save() is now a method of the user entity.
  // user_save($user, array('data' => array('session_limit' => 1)));
  // 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, 3);
  // @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, 5);
  // Set the default session limit.
  \Drupal::configFactory()
    ->getEditable('session_limit.settings')
    ->set('session_limit_max', 2)
    ->save();
  // Check if the user has access to only 1 session.
  $this
    ->assertSessionLogout(1, $user);
}