| 7 user.test | UserRoleAdminTestCase::testRoleWeightChange() |
| 8 user.test | UserRoleAdminTestCase::testRoleWeightChange() |
Test user role weight change operation.
File
- modules/
user/ user.test, line 1931 - Tests for user.module.
Code
function testRoleWeightChange() {
$this->drupalLogin($this->admin_user);
// Pick up a random role and get its weight.
$rid = array_rand(user_roles());
$role = user_role_load($rid);
$old_weight = $role->weight;
// Change the role weight and submit the form.
$edit = array('roles[' . $rid . '][weight]' => $old_weight + 1);
$this->drupalPost('admin/people/permissions/roles', $edit, t('Save order'));
$this->assertText(t('The role settings have been updated.'), t('The role settings form submitted successfully.'));
// Retrieve the saved role and compare its weight.
$role = user_role_load($rid);
$new_weight = $role->weight;
$this->assertTrue(($old_weight + 1) == $new_weight, t('Role weight updated successfully.'));
}
Login or register to post comments