public function NodeAccessPagerTest::testCommentPager

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

File

drupal/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php, line 42
Definition of Drupal\node\Tests\NodeAccessPagerTest.

Class

NodeAccessPagerTest
Tests pagination with a node access module enabled.

Namespace

Drupal\node\Tests

Code

public function testCommentPager() {

  // Create a node.
  $node = $this
    ->drupalCreateNode();

  // Create 60 comments.
  for ($i = 0; $i < 60; $i++) {
    $comment = entity_create('comment', array(
      'nid' => $node->nid,
      'subject' => $this
        ->randomName(),
      'comment_body' => array(
        LANGUAGE_NOT_SPECIFIED => array(
          array(
            'value' => $this
              ->randomName(),
          ),
        ),
      ),
    ));
    $comment
      ->save();
  }
  $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
    ->label());
  $this
    ->assertText(t('Comments'));
  $this
    ->assertRaw('page=1');
  $this
    ->assertNoRaw('page=2');
}