function NodeAccessPagerTestCase::testCommentPager

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

File

modules/node/node.test, line 2787

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');
}

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