Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / tests / src / Functional / CommentPreviewTest.php
similarity index 92%
rename from web/core/modules/comment/src/Tests/CommentPreviewTest.php
rename to web/core/modules/comment/tests/src/Functional/CommentPreviewTest.php
index 1b07fe600b08abd105d1d9ecea533b661b887318..89ac6681de0be5fc0ee02ed4cf3e2d5ce2474e23 100644 (file)
@@ -1,11 +1,12 @@
 <?php
 
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
 
 use Drupal\comment\CommentManagerInterface;
 use Drupal\Component\Render\MarkupInterface;
 use Drupal\Core\Datetime\DrupalDateTime;
 use Drupal\comment\Entity\Comment;
+use Drupal\Tests\TestFileCreationTrait;
 
 /**
  * Tests comment preview.
@@ -14,6 +15,10 @@ use Drupal\comment\Entity\Comment;
  */
 class CommentPreviewTest extends CommentTestBase {
 
+  use TestFileCreationTrait {
+    getTestFiles as drupalGetTestFiles;
+  }
+
   /**
    * The profile to install as a basis for testing.
    *
@@ -105,16 +110,13 @@ class CommentPreviewTest extends CommentTestBase {
     $this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.');
 
     // Store the content of this page.
-    $content = $this->getRawContent();
     $this->drupalPostForm(NULL, [], 'Save');
     $this->assertText('Your comment has been posted.');
     $elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article');
     $this->assertEqual(1, count($elements));
 
-    // Reset the content of the page to simulate the browser's back button, and
-    // re-submit the form.
-    $this->setRawContent($content);
-    $this->drupalPostForm(NULL, [], 'Save');
+    // Go back and re-submit the form.
+    $this->getSession()->getDriver()->back();
     $this->assertText('Your comment has been posted.');
     $elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article');
     $this->assertEqual(2, count($elements));
@@ -173,11 +175,11 @@ class CommentPreviewTest extends CommentTestBase {
 
     // Submit the form using the displayed values.
     $displayed = [];
-    $displayed['subject[0][value]'] = (string) current($this->xpath("//input[@id='edit-subject-0-value']/@value"));
-    $displayed['comment_body[0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-0-value']"));
-    $displayed['uid'] = (string) current($this->xpath("//input[@id='edit-uid']/@value"));
-    $displayed['date[date]'] = (string) current($this->xpath("//input[@id='edit-date-date']/@value"));
-    $displayed['date[time]'] = (string) current($this->xpath("//input[@id='edit-date-time']/@value"));
+    $displayed['subject[0][value]'] = current($this->xpath("//input[@id='edit-subject-0-value']"))->getValue();
+    $displayed['comment_body[0][value]'] = current($this->xpath("//textarea[@id='edit-comment-body-0-value']"))->getValue();
+    $displayed['uid'] = current($this->xpath("//input[@id='edit-uid']"))->getValue();
+    $displayed['date[date]'] = current($this->xpath("//input[@id='edit-date-date']"))->getValue();
+    $displayed['date[time]'] = current($this->xpath("//input[@id='edit-date-time']"))->getValue();
     $this->drupalPostForm('comment/' . $comment->id() . '/edit', $displayed, t('Save'));
 
     // Check that the saved comment is still correct.