You are here

public function FieldAccessTest::testPassAccess in User protect 8

Tests field access for the user's password.

File

tests/src/Kernel/FieldAccessTest.php, line 66

Class

FieldAccessTest
Tests field access for each UserProtection plugin that protects a field.

Namespace

Drupal\Tests\userprotect\Kernel

Code

public function testPassAccess() {

  // Create an account with no protection. The logged in user should have the
  // privileges to edit this account's password.
  $account = $this
    ->drupalCreateUser();
  $this
    ->assertTrue($account->pass
    ->access('edit', $this->userAdmin), 'User admin can edit password of non-protected user.');

  // Create a protected account. The logged in user should NOT have the
  // privileges to edit this account's password.
  $protected_account = $this
    ->createProtectedUser([
    'user_pass',
  ]);
  $this
    ->assertFalse($protected_account->pass
    ->access('edit', $this->userAdmin), 'User admin cannot edit password of protected user.');
}