You are here

public function NodeAccessPagerTestCase::testForumPager in Drupal 7

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

File

modules/node/node.test, line 2762
Tests for node.module.

Class

NodeAccessPagerTestCase
Tests pagination with a node access module enabled.

Code

public function testForumPager() {

  // Look up the forums vocabulary ID.
  $vid = variable_get('forum_nav_vocabulary', 0);
  $this
    ->assertTrue($vid, 'Forum navigation vocabulary ID is set.');

  // Look up the general discussion term.
  $tree = taxonomy_get_tree($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(
        LANGUAGE_NONE => array(
          array(
            'tid' => $tid,
            'vid' => $vid,
            'vocabulary_machine_name' => 'forums',
          ),
        ),
      ),
    ));
  }

  // 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->web_user);
  $this
    ->drupalGet('forum/' . $tid);
  $this
    ->assertRaw('page=1');
  $this
    ->assertNoRaw('page=2');
}