public function DisableFieldTest::testDisableFieldOnAddFormEnableForCertainRoles in Disable Field 8.2
Enable the field for certain roles on the content edit form.
File
- tests/
src/ Functional/ DisableFieldTest.php, line 172
Class
- DisableFieldTest
- Disable field tests.
Namespace
Drupal\Tests\disable_field\FunctionalCode
public function testDisableFieldOnAddFormEnableForCertainRoles() : void {
$this
->fieldUIAddNewField('admin/structure/types/manage/test', 'test', 'Test field', 'string', [], [
'disable_field[add][disable]' => 'roles_enable',
'disable_field[add][roles][]' => [
$this->role1,
],
]);
// Make sure the field is disabled for all roles. Even the admin user.
$this
->drupalGet('node/add/test');
$this
->checkIfFieldIsDisabledByFieldName('field_test');
$this
->drupalLogin($this->user1);
$this
->drupalGet('node/add/test');
$this
->checkIfFieldIsNotDisabledByFieldName('field_test');
$this
->drupalLogin($this->user2);
$this
->drupalGet('node/add/test');
$this
->checkIfFieldIsDisabledByFieldName('field_test');
}