public function DiffPluginVariousTest::testCommentPlugin in Diff 8
Tests the comment plugin.
@covers \Drupal\diff\Plugin\diff\Field\CommentFieldBuilder
File
- tests/
src/ Functional/ DiffPluginVariousTest.php, line 66
Class
- DiffPluginVariousTest
- Tests the Diff module plugins.
Namespace
Drupal\Tests\diff\FunctionalCode
public function testCommentPlugin() {
// Add the comment field to articles.
$this
->addDefaultCommentField('node', 'article');
// Create an article with comments enabled..
$title = 'Sample article';
$edit = array(
'title[0][value]' => $title,
'body[0][value]' => '<p>Revision 1</p>',
'comment[0][status]' => CommentItemInterface::OPEN,
);
$this
->drupalPostNodeForm('node/add/article', $edit, t('Save and publish'));
$node = $this
->drupalGetNodeByTitle($title);
// Edit the article and close its comments.
$edit = array(
'comment[0][status]' => CommentItemInterface::CLOSED,
'revision' => TRUE,
);
$this
->drupalPostNodeForm('node/' . $node
->id() . '/edit', $edit, t('Save and keep published'));
// Check the difference between the last two revisions.
$this
->clickLink(t('Revisions'));
$this
->drupalPostForm(NULL, NULL, t('Compare selected revisions'));
$this
->assertText('Comments');
$this
->assertText('Comments for this entity are open.');
$this
->assertText('Comments for this entity are closed.');
}