public function DisableFieldTest::testDisableFieldOnAddFormDisableForCertainRoles in Disable Field 8.2
Disable the field for certain roles on the content add form.
File
- tests/
src/ Functional/ DisableFieldTest.php, line 150
Class
- DisableFieldTest
- Disable field tests.
Namespace
Drupal\Tests\disable_field\FunctionalCode
public function testDisableFieldOnAddFormDisableForCertainRoles() : void {
$this
->fieldUIAddNewField('admin/structure/types/manage/test', 'test', 'Test field', 'string', [], [
'disable_field[add][disable]' => 'roles',
'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
->checkIfFieldIsNotDisabledByFieldName('field_test');
$this
->drupalLogin($this->user1);
$this
->drupalGet('node/add/test');
$this
->checkIfFieldIsDisabledByFieldName('field_test');
$this
->drupalLogin($this->user2);
$this
->drupalGet('node/add/test');
$this
->checkIfFieldIsNotDisabledByFieldName('field_test');
}