function CommentActionsTest::testCommentPublishUnpublishActions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/Tests/CommentActionsTest.php \Drupal\comment\Tests\CommentActionsTest::testCommentPublishUnpublishActions()
Tests comment publish and unpublish actions.
File
- core/
modules/ comment/ src/ Tests/ CommentActionsTest.php, line 29 - Contains \Drupal\comment\Tests\CommentActionsTest.
Class
- CommentActionsTest
- Tests actions provided by the Comment module.
Namespace
Drupal\comment\TestsCode
function testCommentPublishUnpublishActions() {
$this
->drupalLogin($this->webUser);
$comment_text = $this
->randomMachineName();
$subject = $this
->randomMachineName();
$comment = $this
->postComment($this->node, $comment_text, $subject);
// Unpublish a comment.
$action = entity_load('action', 'comment_unpublish_action');
$action
->execute(array(
$comment,
));
$this
->assertTrue($comment
->isPublished() === FALSE, 'Comment was unpublished');
// Publish a comment.
$action = entity_load('action', 'comment_publish_action');
$action
->execute(array(
$comment,
));
$this
->assertTrue($comment
->isPublished() === TRUE, 'Comment was published');
}