You are here

public function UserProtectionPermissionsTest::testNoEditOwnMail in User protect 8

Tests edit mail without permission "userprotect.mail.edit".

Tests if an user without the permission "userprotect.mail.edit" cannot edit its own mail address.

File

tests/src/Functional/UserProtectionPermissionsTest.php, line 69

Class

UserProtectionPermissionsTest
Tests if "change own" User Protect permissions are respected.

Namespace

Drupal\Tests\userprotect\Functional

Code

public function testNoEditOwnMail() {

  // Create account that may NOT edit its own mail address.
  $account = $this
    ->drupalCreateUser([
    'userprotect.account.edit',
  ]);
  $expected_mail = $account
    ->getEmail();
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('user/' . $account
    ->id() . '/edit');
  $this
    ->assertSession()
    ->fieldDisabled('mail');
}