public function AdministerUsersByRoleTestCase::setUp in Administer Users by Role 6
Same name and namespace in other branches
- 7.2 administerusersbyrole.test \AdministerUsersByRoleTestCase::setUp()
- 7 administerusersbyrole.test \AdministerUsersByRoleTestCase::setUp()
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. A temporary files directory is created with the same name as the database prefix.
Parameters
...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
Overrides DrupalWebTestCase::setUp
File
- ./
administerusersbyrole.test, line 56 - Test Administer Users by Role.
Class
- AdministerUsersByRoleTestCase
- @file Test Administer Users by Role.
Code
public function setUp() {
parent::setUp('administerusersbyrole');
// make sure our immediate dependencies are enabled, since parent::setUp() doesn't check this for us
$this
->assertTrue(module_exists('administerusersbyrole'), "administerusersbyrole.module isn't installed");
$this
->createUserWithRole('noroles', array());
$this
->createRolesAndUsers('alpha', FALSE);
// 'alpha and other' editor
$perms = array(
'access administration pages',
'access content',
'administer users',
_administerusersbyrole_build_perm_string('alpha', 'edit', TRUE),
);
$this
->checkPermissions(array(), TRUE);
$this->roles['alpha_o_ed'] = $this
->drupalCreateRole($perms, 'alpha_o_ed');
$this
->createUserWithRole('alpha_o_ed', array(
'alpha_o_ed',
));
// 'alpha and other' deletor
$perms = array(
'access administration pages',
'access content',
'administer users',
_administerusersbyrole_build_perm_string('alpha', 'delete', TRUE),
);
$this
->checkPermissions(array(), TRUE);
$this->roles['alpha_o_del'] = $this
->drupalCreateRole($perms, 'alpha_o_del');
$this
->createUserWithRole('alpha_o_del', array(
'alpha_o_del',
));
$this
->createRolesAndUsers('beta', TRUE);
// 'beta and other' editor
$perms = array(
'access administration pages',
'access content',
'administer users',
_administerusersbyrole_build_perm_string('beta', 'edit', TRUE),
);
$this
->checkPermissions(array(), TRUE);
$this->roles['beta_o_ed'] = $this
->drupalCreateRole($perms, 'beta_o_ed');
$this
->createUserWithRole('beta_o_ed', array(
'beta_o_ed',
));
$this
->createUserWithRole('alphabeta', array(
'alpha',
'beta',
));
// all_editor
$perms = array(
'access administration pages',
'access content',
'administer users',
'edit users with no custom roles',
);
foreach ($this->roles as $roleName => $roleID) {
$perms[] = _administerusersbyrole_build_perm_string($roleName, 'edit', FALSE);
}
$this
->checkPermissions(array(), TRUE);
$this->roles['all_editor'] = $this
->drupalCreateRole($perms, 'all_editor');
$this
->createUserWithRole('all_editor', array(
'all_editor',
));
// all_deletor
$perms = array(
'access administration pages',
'access content',
'administer users',
'delete users with no custom roles',
);
foreach ($this->roles as $roleName => $roleID) {
$perms[] = _administerusersbyrole_build_perm_string($roleName, 'delete', FALSE);
}
$this
->checkPermissions(array(), TRUE);
$this->roles['all_deletor'] = $this
->drupalCreateRole($perms, 'all_deletor');
$this
->createUserWithRole('all_deletor', array(
'all_deletor',
));
// creator
$perms = array(
'access administration pages',
'access content',
'administer users',
'create users',
);
$this
->checkPermissions(array(), TRUE);
$this->roles['creator'] = $this
->drupalCreateRole($perms, 'creator');
$this
->createUserWithRole('creator', array(
'creator',
));
}