Created
July 11, 2017 05:41
-
-
Save gnuget/b5064ccb45dc5e481a28946785391777 to your computer and use it in GitHub Desktop.
Tests Flat Comments.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\comment\Tests; | |
use Drupal\comment\CommentManagerInterface; | |
/** | |
* Tests to make sure the comment number increments properly. | |
* | |
* @group comment | |
*/ | |
class CommentFlatTest extends CommentTestBase { | |
/** | |
* Tests the comment threading. | |
*/ | |
public function testCommentFlatDelete() { | |
// Set comments to have a subject with preview disabled. | |
$this->drupalLogin($this->adminUser); | |
$this->setCommentPreview(DRUPAL_DISABLED); | |
$this->setCommentForm(TRUE); | |
$this->setCommentSubject(TRUE); | |
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.'); | |
// Create a node. | |
$this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->adminUser->id()]); | |
// Post comment #1. | |
$subject_text = $this->randomMachineName(); | |
$comment_text = $this->randomMachineName(); | |
$comment1 = $this->postComment($this->node, $comment_text, $subject_text, TRUE); | |
// Confirm that the comment was created and has the correct threading. | |
$this->assertTrue($this->commentExists($comment1), 'Comment #1. Comment found.'); | |
// Reply to comment #1 creating comment #1_2. | |
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment1->id()); | |
$comment1_2 = $this->postComment(NULL, $this->randomMachineName(), '', TRUE); | |
// Confirm that the comment was created and is not in a thread. | |
$this->assertTrue($this->commentExists($comment1_2, FALSE), 'Comment #1_2. Reply found.'); | |
// Reply to comment #1_2 creating comment #1_2_3. | |
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment1_2->id()); | |
$comment1_2_3 = $this->postComment(NULL, $this->randomMachineName(), $this->randomMachineName(), TRUE); | |
// Confirm that the comment was created and is not in a thread. | |
$this->assertTrue($this->commentExists($comment1_2_3, FALSE), 'Comment #1_2_3. Second reply found.'); | |
// Delete the first comment. | |
$this->deleteComment($comment1); | |
// Confirm that the rest of the comments are still there. | |
$this->assertTrue($this->commentExists($comment1_2_3, FALSE), 'Comment #1_2_3. Second reply found.'); | |
$this->assertTrue($this->commentExists($comment1_2, FALSE), 'Comment #1_3. Reply found.'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment