Chris@0: addDefaultCommentField('node', 'book'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests comments in book export. Chris@0: */ Chris@0: public function testBookCommentPrint() { Chris@0: $book_node = Node::create([ Chris@0: 'type' => 'book', Chris@0: 'title' => 'Book title', Chris@0: 'body' => 'Book body', Chris@0: ]); Chris@0: $book_node->book['bid'] = 'new'; Chris@0: $book_node->save(); Chris@0: Chris@0: $comment_subject = $this->randomMachineName(8); Chris@0: $comment_body = $this->randomMachineName(8); Chris@0: $comment = Comment::create([ Chris@0: 'subject' => $comment_subject, Chris@0: 'comment_body' => $comment_body, Chris@0: 'entity_id' => $book_node->id(), Chris@0: 'entity_type' => 'node', Chris@0: 'field_name' => 'comment', Chris@0: 'status' => CommentInterface::PUBLISHED, Chris@0: ]); Chris@0: $comment->save(); Chris@0: Chris@0: $commenting_user = $this->drupalCreateUser(['access printer-friendly version', 'access comments', 'post comments']); Chris@0: $this->drupalLogin($commenting_user); Chris@0: Chris@0: $this->drupalGet('node/' . $book_node->id()); Chris@0: Chris@0: $this->assertText($comment_subject, 'Comment subject found'); Chris@0: $this->assertText($comment_body, 'Comment body found'); Chris@0: $this->assertText(t('Add new comment'), 'Comment form found'); Chris@0: $this->assertField('subject[0][value]', 'Comment form subject found'); Chris@0: Chris@0: $this->drupalGet('book/export/html/' . $book_node->id()); Chris@0: Chris@0: $this->assertText(t('Comments'), 'Comment thread found'); Chris@0: $this->assertText($comment_subject, 'Comment subject found'); Chris@0: $this->assertText($comment_body, 'Comment body found'); Chris@0: Chris@0: $this->assertNoText(t('Add new comment'), 'Comment form not found'); Chris@0: $this->assertNoField('subject[0][value]', 'Comment form subject not found'); Chris@0: } Chris@0: Chris@0: }