1 comment.test public CommentAuthorDeletionTestCase::testAuthorDeletion()

Tests that comments are correctly deleted when their author is deleted.

File

core/modules/comment/tests/comment.test, line 2390
Tests for the Comment module.

Class

CommentAuthorDeletionTestCase
Tests the behavior of comments when the comment author is deleted.

Code

public function testAuthorDeletion() {
  // Create a comment as the admin user.
  $this->backdropLogin($this->admin_user);
  $comment = $this->postComment($this->node, $this->randomName());
  $this->assertTrue($this->commentExists($comment), t('Comment is displayed initially.'));
  $this->backdropLogout();

  // Delete the admin user, and check that the node which displays the
  // comment can still be viewed, but the comment itself does not appear
  // there.
  user_delete($this->admin_user->uid);
  $this->backdropGet('node/' . $this->node->nid);
  $this->assertResponse(200, t('Node page is accessible after the comment author is deleted.'));
  $this->assertFalse($this->commentExists($comment), t('Comment is not displayed after the comment author is deleted.'));
}