1 comment.test | CommentContentRebuild::testCommentRebuild() |
Tests the rebuilding of comment's content arrays on calling comment_view().
File
- core/
modules/ comment/ tests/ comment.test, line 1903 - Tests for the Comment module.
Class
- CommentContentRebuild
- Tests comment content rebuilding.
Code
function testCommentRebuild() {
// Update the comment settings so preview isn't required.
$this->backdropLogin($this->admin_user);
$this->setCommentSubject(COMMENT_TITLE_CUSTOM);
$this->setCommentPreview(BACKDROP_OPTIONAL);
$this->backdropLogout();
// Log in as the web user and add the comment.
$this->backdropLogin($this->web_user);
$title_text = $this->randomName();
$comment_text = $this->randomName();
$comment = $this->postComment($this->node, $comment_text, $title_text, TRUE);
$comment_loaded = comment_load($comment->id);
$this->assertTrue($this->commentExists($comment), 'Comment found.');
// Add the property to the content array and then see if it still exists on build.
$comment_loaded->content['test_property'] = array('#value' => $this->randomString());
$built_content = comment_view($comment_loaded, $this->node);
// This means that the content was rebuilt as the added test property no longer exists.
$this->assertFalse(isset($built_content['test_property']), 'Comment content was emptied before being built.');
}