Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / node / tests / src / Functional / NodeTranslationUITest.php
index fa0ad13b3c75b6cd3f58a0db657f869e83df8e22..54d9c7303846acd4dbbb0b665f71623c7e80b52d 100644 (file)
@@ -27,6 +27,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
     'url.path.parent',
     'url.query_args:_wrapper_format',
     'user.roles',
+    'url.path.is_front',
     // These two cache contexts are added by BigPipe.
     'cookies:big_pipe_nojs',
     'session.exists',
@@ -99,7 +100,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
     $add_url = Url::fromRoute("entity.$entity_type_id.content_translation_add", [
       $entity->getEntityTypeId() => $entity->id(),
       'source' => $default_langcode,
-      'target' => $langcode
+      'target' => $langcode,
     ], ['language' => $language]);
     $edit = $this->getEditValues($values, $langcode);
     $edit['status[value]'] = FALSE;
@@ -284,7 +285,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
       $translation = $node->addTranslation($langcode, $values[$langcode]);
       // Publish and promote the translation to frontpage.
       $translation->setPromoted(TRUE);
-      $translation->setPublished(TRUE);
+      $translation->setPublished();
     }
     $node->save();
 
@@ -501,4 +502,28 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
     $this->assertNoText('First rev en title');
   }
 
+  /**
+   * Test that title is not escaped (but XSS-filtered) for details form element.
+   */
+  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->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image/storage', $edit, t('Save field settings'));
+
+    // Make the image field non-translatable.
+    $edit = ['settings[node][article][fields][field_image]' => FALSE];
+    $this->drupalPostForm('admin/config/regional/content-language', $edit, t('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);
+  }
+
 }