function PagerTest::testNoLimit

Same name in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/PagerTest.php \Drupal\Tests\views\Functional\Plugin\PagerTest::testNoLimit()
  2. 8.9.x core/modules/views/tests/src/Functional/Plugin/PagerTest.php \Drupal\Tests\views\Functional\Plugin\PagerTest::testNoLimit()
  3. 11.x core/modules/views/tests/src/Functional/Plugin/PagerTest.php \Drupal\Tests\views\Functional\Plugin\PagerTest::testNoLimit()

Tests the none-pager-query.

File

core/modules/views/tests/src/Functional/Plugin/PagerTest.php, line 224

Class

PagerTest
Tests the pluggable pager system.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testNoLimit() : void {
    // Create 11 nodes and make sure that everyone is returned.
    // We create 11 nodes, because the default pager plugin had 10 items per page.
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    for ($i = 0; $i < 11; $i++) {
        $this->drupalCreateNode();
    }
    $view = Views::getView('test_pager_none');
    $this->executeView($view);
    $this->assertCount(11, $view->result, 'Make sure that every item is returned in the result');
    // Setup and test an offset.
    $view = Views::getView('test_pager_none');
    $view->setDisplay();
    $pager = [
        'type' => 'none',
        'options' => [
            'offset' => 3,
        ],
    ];
    $view->display_handler
        ->setOption('pager', $pager);
    $this->executeView($view);
    $this->assertCount(8, $view->result, 'Make sure that every item beside the first three is returned in the result');
    // Check some public functions.
    $this->assertFalse($view->pager
        ->usePager());
    $this->assertFalse($view->pager
        ->useCountQuery());
    $this->assertEquals(0, $view->pager
        ->getItemsPerPage());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.