ENHANCEMENT: Check case of deleting a comment that has child comments, marking said comment as 'deleted'

This commit is contained in:
Gordon Anderson 2015-02-07 12:21:39 +07:00
parent 04b1b62b85
commit 070a73cb33

View File

@ -56,4 +56,23 @@ class CommentingControllerTests extends FunctionalTest {
public function testDoCommentsForm() {
$this->markTestIncomplete("Not implemented");
}
public function testDeleteWithChildComments() {
$this->logInAs('commentadmin');
// create minimal parent hierarchy, namely parent and child
$comment1 = $this->objFromFixture('Comment', 'firstComA');
$comment2 = $this->objFromFixture('Comment', 'secondComC');
$comment2->ParentCommentID = $comment1->ID;
$comment2->write();
// check permissions for deletion of comment
$this->assertEquals(true, $comment1->canDelete());
// try to delete the parent comment
$response = $this->get('CommentingController/delete/'.$comment1->ID);
$check = DataObject::get_by_id('Comment', $comment1->ID);
$this->assertEquals($check->MarkedAsDeleted, true);
}
}