You are here

public function NodeAccessPagerTest::testForumPager in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/NodeAccessPagerTest.php \Drupal\node\Tests\NodeAccessPagerTest::testForumPager()

Tests the forum node pager for nodes with multiple grants per realm.

File

core/modules/node/src/Tests/NodeAccessPagerTest.php, line 75
Contains \Drupal\node\Tests\NodeAccessPagerTest.

Class

NodeAccessPagerTest
Tests access controlled node views have the right amount of comment pages.

Namespace

Drupal\node\Tests

Code

public function testForumPager() {

  // Look up the forums vocabulary ID.
  $vid = $this
    ->config('forum.settings')
    ->get('vocabulary');
  $this
    ->assertTrue($vid, 'Forum navigation vocabulary ID is set.');

  // Look up the general discussion term.
  $tree = \Drupal::entityManager()
    ->getStorage('taxonomy_term')
    ->loadTree($vid, 0, 1);
  $tid = reset($tree)->tid;
  $this
    ->assertTrue($tid, 'General discussion term is found in the forum vocabulary.');

  // Create 30 nodes.
  for ($i = 0; $i < 30; $i++) {
    $this
      ->drupalCreateNode(array(
      'nid' => NULL,
      'type' => 'forum',
      'taxonomy_forums' => array(
        array(
          'target_id' => $tid,
        ),
      ),
    ));
  }

  // View the general discussion forum page. With the default 25 nodes per
  // page there should be two pages for 30 nodes, no more.
  $this
    ->drupalLogin($this->webUser);
  $this
    ->drupalGet('forum/' . $tid);
  $this
    ->assertRaw('page=1');
  $this
    ->assertNoRaw('page=2');
}