You are here

public function DisableFieldTest::testDisableFieldOnAddFormDisableForAllRoles in Disable Field 8.2

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

File

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

Class

DisableFieldTest
Disable field tests.

Namespace

Drupal\Tests\disable_field\Functional

Code

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

  // 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
    ->checkIfFieldIsDisabledByFieldName('field_test');
  $this
    ->drupalLogin($this->user2);
  $this
    ->drupalGet('node/add/test');
  $this
    ->checkIfFieldIsDisabledByFieldName('field_test');
}