You are here

private function AdministerUsersByRoleTestCase::createUserWithRole in Administer Users by Role 7

Same name and namespace in other branches
  1. 6 administerusersbyrole.test \AdministerUsersByRoleTestCase::createUserWithRole()
  2. 7.2 administerusersbyrole.test \AdministerUsersByRoleTestCase::createUserWithRole()
2 calls to AdministerUsersByRoleTestCase::createUserWithRole()
AdministerUsersByRoleTestCase::createRolesAndUsers in ./administerusersbyrole.test
AdministerUsersByRoleTestCase::setUp in ./administerusersbyrole.test
Sets up a Drupal site for running functional and integration tests.

File

./administerusersbyrole.test, line 20
Test Administer Users by Role.

Class

AdministerUsersByRoleTestCase
@file Test Administer Users by Role.

Code

private function createUserWithRole($userName, $roleNames) {
  $roleIDs = array();
  foreach ($roleNames as $roleName) {
    $roleIDs[$this->roles[$roleName]] = $this->roles[$roleName];
  }
  $userInfo = array(
    'name' => $userName,
    'mail' => "{$userName}@example.com",
    'pass' => 'cheese',
    'roles' => $roleIDs,
    'status' => 1,
  );
  $this->users[$userName] = user_save(NULL, $userInfo);
  $this->users[$userName]->pass_raw = 'cheese';
  $this
    ->assertTrue($this->users[$userName]->uid > 0, "Unable to create user {$userName}.");
}