function CommentActionsTest::testCommentPublishUnpublishActions

Tests comment publish and unpublish actions.

File

drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php, line 33
Definition of Drupal\comment\Tests\CommentActionsTest.

Class

CommentActionsTest
Tests actions provided by the Comment module.

Namespace

Drupal\comment\Tests

Code

function testCommentPublishUnpublishActions() {
  $this
    ->drupalLogin($this->web_user);
  $comment_text = $this
    ->randomName();
  $subject = $this
    ->randomName();
  $comment = $this
    ->postComment($this->node, $comment_text, $subject);

  // Unpublish a comment.
  $action = entity_load('action', 'comment_unpublish_action');
  $action
    ->execute(array(
    $comment,
  ));
  $this
    ->assertEqual($comment->status->value, COMMENT_NOT_PUBLISHED, 'Comment was unpublished');

  // Publish a comment.
  $action = entity_load('action', 'comment_publish_action');
  $action
    ->execute(array(
    $comment,
  ));
  $this
    ->assertEqual($comment->status->value, COMMENT_PUBLISHED, 'Comment was published');
}