function UserFieldsAccessChangeTest::testUserFieldAccess
Same name in other branches
- 9 core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php \Drupal\Tests\user\Functional\Views\UserFieldsAccessChangeTest::testUserFieldAccess()
- 10 core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php \Drupal\Tests\user\Functional\Views\UserFieldsAccessChangeTest::testUserFieldAccess()
- 11.x core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php \Drupal\Tests\user\Functional\Views\UserFieldsAccessChangeTest::testUserFieldAccess()
Tests if another module can change field access.
File
-
core/
modules/ user/ tests/ src/ Functional/ Views/ UserFieldsAccessChangeTest.php, line 34
Class
- UserFieldsAccessChangeTest
- Checks changing entity and field access.
Namespace
Drupal\Tests\user\Functional\ViewsCode
public function testUserFieldAccess() {
$this->drupalGet('test_user_fields_access');
// User has access to name and created date by default.
$this->assertText(t('Name'));
$this->assertText(t('Created'));
// User does not by default have access to init, mail and status.
$this->assertNoText(t('Init'));
$this->assertNoText(t('Email'));
$this->assertNoText(t('Status'));
// Assign sub-admin role to grant extra access.
$user = $this->drupalCreateUser([
'sub-admin',
]);
$this->drupalLogin($user);
$this->drupalGet('test_user_fields_access');
// Access for init, mail and status is added in hook_entity_field_access().
$this->assertText(t('Init'));
$this->assertText(t('Email'));
$this->assertText(t('Status'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.