function UserEditTest::testUserMailFieldAccess

Same name in other branches
  1. 11.x core/modules/user/tests/src/Functional/UserEditTest.php \Drupal\Tests\user\Functional\UserEditTest::testUserMailFieldAccess()

Tests the account form implements entity field access for mail.

File

core/modules/user/tests/src/Functional/UserEditTest.php, line 253

Class

UserEditTest
Tests user edit page.

Namespace

Drupal\Tests\user\Functional

Code

public function testUserMailFieldAccess() : void {
    \Drupal::state()->set('user_access_test_forbid_mail_edit', TRUE);
    \Drupal::service('module_installer')->install([
        'user_access_test',
    ]);
    $user = $this->drupalCreateUser();
    $this->drupalLogin($user);
    $this->drupalGet("user/" . $user->id() . "/edit");
    $this->assertFalse($this->getSession()
        ->getPage()
        ->hasField('mail'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.