You are here

public function PagerTest::testNoLimit in Views (for Drupal 7) 8.3

Tests the none-pager-query.

File

lib/Drupal/views/Tests/Plugin/PagerTest.php, line 106
Definition of Drupal\views\Tests\Plugin\PagerTest.

Class

PagerTest
Tests the pluggable pager system.

Namespace

Drupal\views\Tests\Plugin

Code

public function testNoLimit() {

  // Create 11 nodes and make sure that everyone is returned.
  // We create 11 nodes, because the default pager plugin had 10 items per page.
  for ($i = 0; $i < 11; $i++) {
    $this
      ->drupalCreateNode();
  }
  $view = $this
    ->getView();
  $this
    ->executeView($view);
  $this
    ->assertEqual(count($view->result), 11, 'Make sure that every item is returned in the result');

  // Setup and test a offset.
  $view = $this
    ->getView();
  $pager = array(
    'type' => 'none',
    'options' => array(
      'offset' => 3,
    ),
  );
  $view->display_handler
    ->setOption('pager', $pager);
  $this
    ->executeView($view);
  $this
    ->assertEqual(count($view->result), 8, 'Make sure that every item beside the first three is returned in the result');

  // Check some public functions.
  $this
    ->assertFalse($view->pager
    ->use_pager());
  $this
    ->assertFalse($view->pager
    ->use_count_query());
  $this
    ->assertEqual($view->pager
    ->get_items_per_page(), 0);
}