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