public function NodeAccessPagerTestCase::testCommentPager

7.x node.test public NodeAccessPagerTestCase::testCommentPager()

Tests the comment pager for nodes with multiple grants per realm.

File

drupal-7.x/modules/node/node.test, line 2585
Tests for node.module.

Class

NodeAccessPagerTestCase
Tests pagination with a node access module enabled.

Code

public function testCommentPager() {
  // Create a node.
  $node = $this->drupalCreateNode();

  // Create 60 comments.
  for ($i = 0; $i < 60; $i++) {
    $comment = new stdClass();
    $comment->cid = 0;
    $comment->pid = 0;
    $comment->uid = $this->web_user->uid;
    $comment->nid = $node->nid;
    $comment->subject = $this->randomName();
    $comment->comment_body = array(
      LANGUAGE_NONE => array(
        array('value' => $this->randomName()),
      ),
    );
    comment_save($comment);
  }

  $this->drupalLogin($this->web_user);

  // View the node page. With the default 50 comments per page there should
  // be two pages (0, 1) but no third (2) page.
  $this->drupalGet('node/' . $node->nid);
  $this->assertText($node->title);
  $this->assertText(t('Comments'));
  $this->assertRaw('page=1');
  $this->assertNoRaw('page=2');
}