public function FieldAccessTest::testRolesAccess in User protect 8
Tests field access for the user's roles.
File
- tests/
src/ Kernel/ FieldAccessTest.php, line 96
Class
- FieldAccessTest
- Tests field access for each UserProtection plugin that protects a field.
Namespace
Drupal\Tests\userprotect\KernelCode
public function testRolesAccess() {
// Create an account with no protection. The logged in user should have the
// privileges to edit this account's roles.
$account = $this
->drupalCreateUser();
$this
->assertTrue($account->roles
->access('edit', $this->userAdmin), 'User admin can edit roles of non-protected user.');
// Create a protected account. The logged in user should NOT have the
// privileges to edit this account's roles.
$protected_account = $this
->createProtectedUser([
'user_roles',
]);
$this
->assertFalse($protected_account->roles
->access('edit', $this->userAdmin), 'User admin cannot edit roles of protected user.');
}