1 user.test UserPermissionsTestCase::testUserRoleChangePermissions()

Verify proper permission changes by user_role_change_permissions().

File

core/modules/user/tests/user.test, line 1352
Tests for user.module.

Class

UserPermissionsTestCase

Code

function testUserRoleChangePermissions() {
  $role_name = $this->role_name;
  $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($role_name, $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.');
}