You are here

public function NodeAccessPagerTestCase::testCommentPager in Drupal 7

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

File

modules/node/node.test, line 2728
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');
}