public function PagerTest::testLimit

Tests the some pager plugin.

File

drupal/core/modules/views/lib/Drupal/views/Tests/Plugin/PagerTest.php, line 163
Definition of Drupal\views\Tests\Plugin\PagerTest.

Class

PagerTest
Tests the pluggable pager system.

Namespace

Drupal\views\Tests\Plugin

Code

public function testLimit() {

  // 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 = views_get_view('test_pager_some');
  $this
    ->executeView($view);
  $this
    ->assertEqual(count($view->result), 5, 'Make sure that only a certain count of items is returned');

  // Setup and test a offset.
  $view = views_get_view('test_pager_some');
  $view
    ->setDisplay();
  $pager = array(
    'type' => 'none',
    'options' => array(
      'offset' => 8,
      'items_per_page' => 5,
    ),
  );
  $view->display_handler
    ->setOption('pager', $pager);
  $this
    ->executeView($view);
  $this
    ->assertEqual(count($view->result), 3, 'Make sure that only a certain count of items is returned');

  // Check some public functions.
  $this
    ->assertFalse($view->pager
    ->usePager());
  $this
    ->assertFalse($view->pager
    ->useCountQuery());
}