You are here

private function AdministerUsersByRoleTestCase::createRolesAndUsers in Administer Users by Role 6

Same name and namespace in other branches
  1. 7.2 administerusersbyrole.test \AdministerUsersByRoleTestCase::createRolesAndUsers()
  2. 7 administerusersbyrole.test \AdministerUsersByRoleTestCase::createRolesAndUsers()
1 call to AdministerUsersByRoleTestCase::createRolesAndUsers()
AdministerUsersByRoleTestCase::setUp in ./administerusersbyrole.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…

File

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

Class

AdministerUsersByRoleTestCase
@file Test Administer Users by Role.

Code

private function createRolesAndUsers($roleName, $allowEditorToDelete) {

  // create basic role
  $this->roles[$roleName] = $this
    ->drupalCreateRole(array(
    'access content',
  ), $roleName);
  $this
    ->createUserWithRole($roleName, array(
    $roleName,
  ));

  // clear permissions cache, so we can use the 'edit users with ...' permission for this role
  $this
    ->checkPermissions(array(), TRUE);

  // create role to edit above role
  $perms = array(
    'access administration pages',
    'access content',
    'administer users',
    _administerusersbyrole_build_perm_string($roleName, 'edit', FALSE),
  );
  if ($allowEditorToDelete) {
    $perms[] = _administerusersbyrole_build_perm_string($roleName, 'delete', FALSE);
  }
  $this->roles["{$roleName}_editor"] = $this
    ->drupalCreateRole($perms, "{$roleName}_editor");
  $this
    ->createUserWithRole("{$roleName}_editor", array(
    "{$roleName}_editor",
  ));
}