// Verify current permissions.
$this->
assertFalse($account->
hasPermission('administer users'
), 'User does not have "administer users" permission.'
);
$this->
assertTrue($account->
hasPermission('access user profiles'
), 'User has "access user profiles" permission.'
);
$this->
assertTrue($account->
hasPermission('administer site configuration'
), 'User has "administer site configuration" permission.'
);
// Change permissions.
$permissions =
[ 'administer users' => 1,
'access user profiles' => 0,
];
user_role_change_permissions($rid,
$permissions);
// Verify proper permission changes.
$this->
assertTrue($account->
hasPermission('administer users'
), 'User now has "administer users" permission.'
);
$this->
assertFalse($account->
hasPermission('access user profiles'
), 'User no longer has "access user profiles" permission.'
);
$this->
assertTrue($account->
hasPermission('administer site configuration'
), 'User still has "administer site configuration" permission.'
);
// Verify the permissions hash has changed.
$current_permissions_hash =
$permissions_hash_generator->
generate($account);
$this->
assertNotEquals($previous_permissions_hash,
$current_permissions_hash, 'Permissions hash has changed.'
);
}