public function AdministerUsersByRoleTestCase::testPermissions in Administer Users by Role 7
Same name and namespace in other branches
- 6 administerusersbyrole.test \AdministerUsersByRoleTestCase::testPermissions()
- 7.2 administerusersbyrole.test \AdministerUsersByRoleTestCase::testPermissions()
File
- ./
administerusersbyrole.test, line 147 - Test Administer Users by Role.
Class
- AdministerUsersByRoleTestCase
- @file Test Administer Users by Role.
Code
public function testPermissions() {
$expectations = array(
// When I'm logged in as...
'nobody' => array(
// ...I can perform these actions on this other user...
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'noroles' => array(
'noroles' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'alpha' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'alpha_editor' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'alpha_o_ed' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'alpha_o_del' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'beta' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'beta_editor' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => TRUE,
'cancel' => TRUE,
),
'beta_editor' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'beta_o_ed' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'alphabeta' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'all_editor' => array(
'noroles' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'all_deletor' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'alpha' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'beta' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'alphabeta' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'creator' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => TRUE,
),
'all_deletor' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'create users' => FALSE,
),
'creator' => array(
'noroles' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alpha_o_del' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'beta_o_ed' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'alphabeta' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'creator' => array(
'edit' => TRUE,
'cancel' => FALSE,
),
'all_editor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'all_deletor' => array(
'edit' => FALSE,
'cancel' => FALSE,
),
'create users' => TRUE,
),
);
foreach ($expectations as $loginUsername => $editUsernames) {
if ($loginUsername !== 'nobody') {
$this
->drupalLogin($this->users[$loginUsername]);
}
foreach ($editUsernames as $k => $v) {
if ($k === 'create users') {
$this
->drupalGet("admin/people/create");
$expectedResult = $v;
if ($expectedResult) {
$this
->assertRaw('This web page allows administrators to register new users.', "My expectation is that {$loginUsername} should be able to create users, but it can't.");
}
else {
$this
->assertRaw('You are not authorized to access this page.', "My expectation is that {$loginUsername} shouldn't be able to create users, but it can.");
}
}
else {
$editUsername = $k;
$operations = $v;
$editUid = $this->users[$editUsername]->uid;
foreach ($operations as $operation => $expectedResult) {
$this
->drupalGet("user/{$editUid}/{$operation}");
if ($expectedResult) {
if ($operation === 'edit') {
$this
->assertRaw("All e-mails from the system will be sent to this address.", "My expectation is that {$loginUsername} should be able to {$operation} {$editUsername}, but it can't.");
}
elseif ($operation === 'cancel') {
$this
->assertRaw("Are you sure you want to cancel the account <em class=\"placeholder\">{$editUsername}</em>?", "My expectation is that {$loginUsername} should be able to {$operation} {$editUsername}, but it can't.");
}
}
else {
$this
->assertTrue(strstr($this
->drupalGetContent(), "You do not have permission to {$operation} <em class=\"placeholder\">{$editUsername}</em>.") || strstr($this
->drupalGetContent(), 'You are not authorized to access this page.'), "My expectation is that {$loginUsername} shouldn't be able to {$operation} {$editUsername}, but it can.");
}
}
}
}
if ($loginUsername !== 'nobody') {
$this
->drupalLogout();
}
}
}