You are here

public function DisableFieldTest::testDisableFieldOnEditFormDisableForAllRoles in Disable Field 8.2

Disable the field for all roles on the content edit form.

File

tests/src/Functional/DisableFieldTest.php, line 214

Class

DisableFieldTest
Disable field tests.

Namespace

Drupal\Tests\disable_field\Functional

Code

public function testDisableFieldOnEditFormDisableForAllRoles() : void {
  $this
    ->fieldUIAddNewField('admin/structure/types/manage/test', 'test', 'Test field', 'string', [], [
    'disable_field[edit][disable]' => 'all',
  ]);

  // Make sure the field is not disabled on the field config edit page.
  $this
    ->drupalGet('/admin/structure/types/manage/test/fields/node.test.field_test');
  $this
    ->checkIfFieldIsNotDisabledByFieldName('default-value-input-field-test');
  $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
    ->checkIfFieldIsDisabledByFieldName('field_test');
  $this
    ->drupalLogin($this->user2);
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $this
    ->checkIfFieldIsDisabledByFieldName('field_test');
}