function FilterFormTest::assertDisabledTextarea

Same name in other branches
  1. 9 core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertDisabledTextarea()
  2. 10 core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertDisabledTextarea()
  3. 11.x core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertDisabledTextarea()

Asserts that a textarea with a given ID has been disabled from editing.

Parameters

string $id: The HTML ID of the textarea.

Return value

bool TRUE if the assertion passed; FALSE otherwise.

1 call to FilterFormTest::assertDisabledTextarea()
FilterFormTest::doFilterFormTestAsNonAdmin in core/modules/filter/tests/src/Functional/FilterFormTest.php
Tests the behavior of the 'text_format' element as a normal user.

File

core/modules/filter/tests/src/Functional/FilterFormTest.php, line 285

Class

FilterFormTest
Tests form elements with associated text formats.

Namespace

Drupal\Tests\filter\Functional

Code

protected function assertDisabledTextarea($id) {
    $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', [
        ':id' => $id,
    ]);
    $this->assertNotEmpty($textarea, new FormattableMarkup('Disabled field @id exists.', [
        '@id' => $id,
    ]));
    $textarea = reset($textarea);
    $expected = 'This field has been disabled because you do not have sufficient permissions to edit it.';
    $this->assertEqual($textarea->getText(), $expected, new FormattableMarkup('Disabled textarea @id hides text in an inaccessible text format.', [
        '@id' => $id,
    ]));
    // Make sure the text format select is not shown.
    $select_id = str_replace('value', 'format--2', $id);
    $this->assertNoSelect($select_id);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.