You are here

function AutoassignroleUserAutoRoleTestCase::testAutomaticRoleAssignment in Auto Assign Role 6

Same name and namespace in other branches
  1. 6.2 tests/autoassignrole.test \AutoassignroleUserAutoRoleTestCase::testAutomaticRoleAssignment()

File

tests/autoassignrole.test, line 298
Autoassignrole functionality tests.

Class

AutoassignroleUserAutoRoleTestCase

Code

function testAutomaticRoleAssignment() {

  // Create a new user who can access the administration settings
  $admin_user = $this
    ->drupalCreateUser(array(
    'access administration pages',
    'administer autoassignrole',
  ));
  $this
    ->drupalLogin($admin_user);
  $edit = $this
    ->getEditValues('automatic_role_assignment');
  $this
    ->drupalPost('admin/user/autoassignrole', $edit, t('Save'));
  $new_user = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($new_user);

  // check the user after login to make sure they have been assigned the appropriate
  // roles
  foreach ($this->roles as $rid => $role) {
    $this
      ->assertTrue(array_key_exists($rid, $this->loggedInUser->roles), "New User has been assigned the role {$role}");
  }
}