// Deliberately use the wrong URL to test
// \Drupal\comment\Controller\CommentController::redirectNode().
$this->
drupalGet('comment/' .
$this->node->
id() . '/reply'
);
// Verify we were correctly redirected.
$this->
assertSession()->
addressEquals(Url::
fromRoute('comment.reply',
['entity_type' => 'node', 'entity' =>
$this->node->
id(), 'field_name' => 'comment'
]));
$this->
drupalGet('comment/reply/node/' .
$this->node->
id() . '/comment/' .
$comment->
id());
$this->
assertSession()->
pageTextContains($subject_text);
$this->
assertSession()->
pageTextContains($comment_text);
$reply =
$this->
postComment(NULL,
$this->
randomMachineName(), '', TRUE
);
$reply_loaded = Comment::
load($reply->
id());
$this->
assertTrue($this->
commentExists($reply, TRUE
), 'Reply found.'
);
$this->
assertEquals($comment->
id(),
$reply_loaded->
getParentComment()->
id(), 'Pid of a reply to a comment is set correctly.'
);
// Check the thread of reply grows correctly.
$this->
assertEquals(rtrim($comment->
getThread(), '/'
) . '.00/',
$reply_loaded->
getThread());
// Second reply to comment #2 creating comment #4.
$this->
drupalGet('comment/reply/node/' .
$this->node->
id() . '/comment/' .
$comment->
id());
$this->
assertSession()->
pageTextContains($comment->
getSubject());
$this->
assertSession()->
pageTextContains($comment->comment_body->value
);
$reply =
$this->
postComment(NULL,
$this->
randomMachineName(),
$this->
randomMachineName(), TRUE
);
$reply_loaded = Comment::
load($reply->
id());
$this->
assertTrue($this->
commentExists($reply, TRUE
), 'Second reply found.'
);
// Check the thread of second reply grows correctly.