function UserPermissionsTestCase::testUserRoleChangePermissions

Verify proper permission changes by user_role_change_permissions().

File

modules/user/user.test, line 1683

Class

UserPermissionsTestCase

Code

function testUserRoleChangePermissions() {
    $rid = $this->rid;
    $account = $this->admin_user;
    // Verify current permissions.
    $this->assertFalse(user_access('administer nodes', $account), 'User does not have "administer nodes" permission.');
    $this->assertTrue(user_access('access user profiles', $account), 'User has "access user profiles" permission.');
    $this->assertTrue(user_access('administer site configuration', $account), 'User has "administer site configuration" permission.');
    // Change permissions.
    $permissions = array(
        'administer nodes' => 1,
        'access user profiles' => 0,
    );
    user_role_change_permissions($rid, $permissions);
    // Verify proper permission changes.
    $this->assertTrue(user_access('administer nodes', $account), 'User now has "administer nodes" permission.');
    $this->assertFalse(user_access('access user profiles', $account), 'User no longer has "access user profiles" permission.');
    $this->assertTrue(user_access('administer site configuration', $account), 'User still has "administer site configuration" permission.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.