Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function CommentNodeAccessTest::testThreadedCommentView

Same name and namespace in other branches
  1. 11.x core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php \Drupal\Tests\comment\Functional\CommentNodeAccessTest::testThreadedCommentView()
  2. 10 core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php \Drupal\Tests\comment\Functional\CommentNodeAccessTest::testThreadedCommentView()
  3. 9 core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php \Drupal\Tests\comment\Functional\CommentNodeAccessTest::testThreadedCommentView()
  4. 8.9.x core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php \Drupal\Tests\comment\Functional\CommentNodeAccessTest::testThreadedCommentView()

Test that threaded comments can be viewed.

File

modules/comment/comment.test, line 1525

Class

CommentNodeAccessTest
Tests comments with node access.

Code

function testThreadedCommentView() {
 $langcode = LANGUAGE_NONE ;
 // Set comments to have subject required and 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 , 'Comment paging changed.');
 $this->drupalLogout ();
 // Post comment.
 $this->drupalLogin ($this->web_user );
 $comment_text = $this->randomName ();
 $comment_subject = $this->randomName ();
 $comment = $this->postComment ($this->node , $comment_text, $comment_subject);
 $comment_loaded = comment_load ($comment->id);
 $this->assertTrue ($this->commentExists ($comment), 'Comment found.');
 // Check comment display.
 $this->drupalGet ('node/' . $this->node ->nid . '/' . $comment->id);
 $this->assertText ($comment_subject, 'Individual comment subject found.');
 $this->assertText ($comment_text, 'Individual comment body found.');
 // Reply to comment, creating second comment.
 $this->drupalGet ('comment/reply/' . $this->node ->nid . '/' . $comment->id);
 $reply_text = $this->randomName ();
 $reply_subject = $this->randomName ();
 $reply = $this->postComment (NULL, $reply_text, $reply_subject, TRUE);
 $reply_loaded = comment_load ($reply->id);
 $this->assertTrue ($this->commentExists ($reply, TRUE), 'Reply found.');
 // Go to the node page and verify comment and reply are visible.
 $this->drupalGet ('node/' . $this->node ->nid);
 $this->assertText ($comment_text);
 $this->assertText ($comment_subject);
 $this->assertText ($reply_text);
 $this->assertText ($reply_subject);
}

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