function NodeTranslationUITest::testDetailsTitleIsNotEscaped

Same name and namespace in other branches
  1. 8.9.x core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testDetailsTitleIsNotEscaped()
  2. 10 core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testDetailsTitleIsNotEscaped()
  3. 11.x core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testDetailsTitleIsNotEscaped()

Tests title is not escaped (but XSS-filtered) for details form element.

File

core/modules/node/tests/src/Functional/NodeTranslationUITest.php, line 557

Class

NodeTranslationUITest
Tests the Node Translation UI.

Namespace

Drupal\Tests\node\Functional

Code

public function testDetailsTitleIsNotEscaped() {
  $this->drupalLogin($this->administrator);
  // Make the image field a multi-value field in order to display a
  // details form element.
  $edit = [
    'cardinality_number' => 2,
  ];
  $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_image/storage');
  $this->submitForm($edit, 'Save field settings');
  // Make the image field non-translatable.
  $edit = [
    'settings[node][article][fields][field_image]' => FALSE,
  ];
  $this->drupalGet('admin/config/regional/content-language');
  $this->submitForm($edit, 'Save configuration');
  // Create a node.
  $nid = $this->createEntity([
    'title' => 'Node with multi-value image field en title',
  ], 'en');
  // Add a French translation and assert the title markup is not escaped.
  $this->drupalGet("node/{$nid}/translations/add/en/fr");
  $markup = 'Image <span class="translation-entity-all-languages">(all languages)</span>';
  $this->assertSession()
    ->assertNoEscaped($markup);
  $this->assertSession()
    ->responseContains($markup);
}

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