<?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.
*/
class CommentPreviewTest extends CommentTestBase {
+ use TestFileCreationTrait {
+ getTestFiles as drupalGetTestFiles;
+ }
+
/**
* The profile to install as a basis for testing.
*
$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));
// 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.