protected function FieldPermissionsUserTest::addUserField in Field Permissions 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/FieldPermissionsUserTest.php \Drupal\Tests\field_permissions\Functional\FieldPermissionsUserTest::addUserField()
Adds a text field to the user entity.
1 call to FieldPermissionsUserTest::addUserField()
- FieldPermissionsUserTest::setUp in tests/
src/ Functional/ FieldPermissionsUserTest.php
File
- tests/
src/ Functional/ FieldPermissionsUserTest.php, line 70
Class
- FieldPermissionsUserTest
- Test field permissions on users.
Namespace
Drupal\Tests\field_permissions\FunctionalCode
protected function addUserField() {
FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'user',
'type' => 'text',
])
->save();
FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'user',
'label' => 'Textfield',
'bundle' => 'user',
])
->save();
$this->entityDisplayRepository
->getFormDisplay('user', 'user', 'default')
->setComponent($this->fieldName)
->save();
$this->entityDisplayRepository
->getFormDisplay('user', 'user', 'register')
->setComponent($this->fieldName)
->save();
$this->entityDisplayRepository
->getViewDisplay('user', 'user')
->setComponent($this->fieldName)
->save();
}