public function CommentActionsTest::testCommentPublishUnpublishActions in Drupal 8
Tests comment publish and unpublish actions.
File
- core/
modules/ comment/ tests/ src/ Functional/ CommentActionsTest.php, line 30
Class
- CommentActionsTest
- Tests actions provided by the Comment module.
Namespace
Drupal\Tests\comment\FunctionalCode
public 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 = Action::load('comment_unpublish_action');
$action
->execute([
$comment,
]);
$this
->assertTrue($comment
->isPublished() === FALSE, 'Comment was unpublished');
$this
->assertArraySubset([
'module' => [
'comment',
],
], $action
->getDependencies());
// Publish a comment.
$action = Action::load('comment_publish_action');
$action
->execute([
$comment,
]);
$this
->assertTrue($comment
->isPublished() === TRUE, 'Comment was published');
}