You are here

protected function ConfigTranslationUiTest::assertDisabledTextarea in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::assertDisabledTextarea()
  2. 10 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::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 ConfigTranslationUiTest::assertDisabledTextarea()
ConfigTranslationUiTest::testTextFormatTranslation in core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
Test text_format translation.

File

core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php, line 1154

Class

ConfigTranslationUiTest
Translate settings and entities to various languages.

Namespace

Drupal\Tests\config_translation\Functional

Code

protected function assertDisabledTextarea($id) {
  $textarea = $this
    ->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', [
    ':id' => $id,
  ]);
  $textarea = reset($textarea);
  $this
    ->assertInstanceOf(NodeElement::class, $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);
  $xpath = $this
    ->assertSession()
    ->buildXPathQuery('//select[@id=:id]', [
    ':id' => $select_id,
  ]);
  $this
    ->assertSession()
    ->elementNotExists('xpath', $xpath);
}