function CommentAuthorDeletionTestCase::testAuthorDeletion

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

File

modules/comment/comment.test, line 2349

Class

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

Code

function testAuthorDeletion() {
    // Create a comment as the admin user.
    $this->drupalLogin($this->admin_user);
    $comment = $this->postComment($this->node, $this->randomName());
    $this->assertTrue($this->commentExists($comment), t('Comment is displayed initially.'));
    $this->drupalLogout();
    // 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->drupalGet('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.'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.