diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-03-04 10:52:33 -0800 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-03-04 10:52:33 -0800 |
commit | b04f183beb5dd2164029533ad2566fd704b56699 (patch) | |
tree | 0c06e74a542c3d89b2e10c3f7038feb43d3ac50a /modules/comment/comment.test | |
parent | 421d010ee6a44250e0909c427f1fbdba7e0251cf (diff) | |
download | brdo-b04f183beb5dd2164029533ad2566fd704b56699.tar.gz brdo-b04f183beb5dd2164029533ad2566fd704b56699.tar.bz2 |
Issue #97327 by PMunn, NROTC_Webmaster, xjm, maartenvg, killes@www.drop.org, gdavid, Zed Pobre: Fixed Data corruption in comment IDs (results in broken threading on PostgreSQL).
Diffstat (limited to 'modules/comment/comment.test')
-rw-r--r-- | modules/comment/comment.test | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/modules/comment/comment.test b/modules/comment/comment.test index 3c85b12bd..4c6755522 100644 --- a/modules/comment/comment.test +++ b/modules/comment/comment.test @@ -2101,3 +2101,98 @@ class CommentFieldsTest extends CommentHelperCase { $this->drupalPost('node/' . $this->node->nid, $edit, t('Save')); } } + +/** + * Tests comment threading. + */ +class CommentThreadingTestCase extends CommentHelperCase { + public static function getInfo() { + return array( + 'name' => 'Comment Threading', + 'description' => 'Test to make sure the comment number increments properly.', + 'group' => 'Comment', + ); + } + + /** + * Tests the comment threading. + */ + function testCommentThreading() { + $langcode = LANGUAGE_NONE; + // Set comments to have a subject with preview disabled. + $this->drupalLogin($this->admin_user); + $this->setCommentPreview(DRUPAL_DISABLED); + $this->setCommentForm(TRUE); + $this->setCommentSubject(TRUE); + $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.')); + $this->drupalLogout(); + + // Create a node. + $this->drupalLogin($this->web_user); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid)); + + // Post comment #1. + $this->drupalLogin($this->web_user); + $subject_text = $this->randomName(); + $comment_text = $this->randomName(); + $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE); + $comment_loaded = comment_load($comment->id); + $this->assertTrue($this->commentExists($comment), 'Comment #1. Comment found.'); + $this->assertEqual($comment_loaded->thread, '01/'); + + // Reply to comment #1 creating comment #2. + $this->drupalLogin($this->web_user); + $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id); + $reply = $this->postComment(NULL, $this->randomName(), '', TRUE); + $reply_loaded = comment_load($reply->id); + $this->assertTrue($this->commentExists($reply, TRUE), 'Comment #2. Reply found.'); + $this->assertEqual($reply_loaded->thread, '01.00/'); + + // Reply to comment #2 creating comment #3. + $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $reply->id); + $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); + $reply_loaded = comment_load($reply->id); + $this->assertTrue($this->commentExists($reply, TRUE), 'Comment #3. Second reply found.'); + $this->assertEqual($reply_loaded->thread, '01.00.00/'); + + // Reply to comment #1 creating comment #4. + $this->drupalLogin($this->web_user); + $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id); + $reply = $this->postComment(NULL, $this->randomName(), '', TRUE); + $reply_loaded = comment_load($reply->id); + $this->assertTrue($this->commentExists($comment), 'Comment #4. Third reply found.'); + $this->assertEqual($reply_loaded->thread, '01.01/'); + + // Post comment #2 overall comment #5. + $this->drupalLogin($this->web_user); + $subject_text = $this->randomName(); + $comment_text = $this->randomName(); + $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE); + $comment_loaded = comment_load($comment->id); + $this->assertTrue($this->commentExists($comment), 'Comment #5. Second comment found.'); + $this->assertEqual($comment_loaded->thread, '02/'); + + // Reply to comment #5 creating comment #6. + $this->drupalLogin($this->web_user); + $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id); + $reply = $this->postComment(NULL, $this->randomName(), '', TRUE); + $reply_loaded = comment_load($reply->id); + $this->assertTrue($this->commentExists($reply, TRUE), 'Comment #6. Reply found.'); + $this->assertEqual($reply_loaded->thread, '02.00/'); + + // Reply to comment #6 creating comment #7. + $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $reply->id); + $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); + $reply_loaded = comment_load($reply->id); + $this->assertTrue($this->commentExists($reply, TRUE), 'Comment #7. Second reply found.'); + $this->assertEqual($reply_loaded->thread, '02.00.00/'); + + // Reply to comment #5 creating comment #8. + $this->drupalLogin($this->web_user); + $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id); + $reply = $this->postComment(NULL, $this->randomName(), '', TRUE); + $reply_loaded = comment_load($reply->id); + $this->assertTrue($this->commentExists($comment), 'Comment #8. Third reply found.'); + $this->assertEqual($reply_loaded->thread, '02.01/'); + } +} |