function CommentBookTest::testBookCommentPrint
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentBookTest.php \Drupal\Tests\comment\Functional\CommentBookTest::testBookCommentPrint()
- 10 core/modules/book/tests/src/Functional/Comment/CommentBookTest.php \Drupal\Tests\book\Functional\Comment\CommentBookTest::testBookCommentPrint()
- 11.x core/modules/book/tests/src/Functional/Comment/CommentBookTest.php \Drupal\Tests\book\Functional\Comment\CommentBookTest::testBookCommentPrint()
Tests comments in book export.
File
-
core/
modules/ comment/ tests/ src/ Functional/ CommentBookTest.php, line 42
Class
- CommentBookTest
- Tests visibility of comments on book pages.
Namespace
Drupal\Tests\comment\FunctionalCode
public function testBookCommentPrint() {
$book_node = Node::create([
'type' => 'book',
'title' => 'Book title',
'body' => 'Book body',
]);
$book_node->book['bid'] = 'new';
$book_node->save();
$comment_subject = $this->randomMachineName(8);
$comment_body = $this->randomMachineName(8);
$comment = Comment::create([
'subject' => $comment_subject,
'comment_body' => $comment_body,
'entity_id' => $book_node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'status' => CommentInterface::PUBLISHED,
]);
$comment->save();
$commenting_user = $this->drupalCreateUser([
'access printer-friendly version',
'access comments',
'post comments',
]);
$this->drupalLogin($commenting_user);
$this->drupalGet('node/' . $book_node->id());
$this->assertText($comment_subject, 'Comment subject found');
$this->assertText($comment_body, 'Comment body found');
$this->assertText(t('Add new comment'), 'Comment form found');
$this->assertField('subject[0][value]', 'Comment form subject found');
$this->drupalGet('book/export/html/' . $book_node->id());
$this->assertText(t('Comments'), 'Comment thread found');
$this->assertText($comment_subject, 'Comment subject found');
$this->assertText($comment_body, 'Comment body found');
$this->assertNoText(t('Add new comment'), 'Comment form not found');
$this->assertNoField('subject[0][value]', 'Comment form subject not found');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.