function SqlBaseTest::testQuery

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php \Drupal\Tests\views\Unit\Plugin\pager\SqlBaseTest::testQuery()
  2. 10 core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php \Drupal\Tests\views\Unit\Plugin\pager\SqlBaseTest::testQuery()

Tests the query() method.

See also

\Drupal\views\Plugin\views\pager\SqlBase::query()

File

core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php, line 70

Class

SqlBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\pager\SqlBase @group views

Namespace

Drupal\Tests\views\Unit\Plugin\pager

Code

public function testQuery() : void {
    $request = new Request([
        'items_per_page' => 'All',
    ]);
    $this->view
        ->expects($this->any())
        ->method('getRequest')
        ->willReturn($request);
    $options = [];
    $this->pager
        ->init($this->view, $this->display, $options);
    $this->pager
        ->query();
    $this->assertSame(10, $this->pager->options['items_per_page']);
    $options = [
        'expose' => [
            'items_per_page' => TRUE,
            'items_per_page_options_all' => TRUE,
        ],
    ];
    $this->pager
        ->init($this->view, $this->display, $options);
    $this->pager
        ->query();
    $this->assertSame(0, $this->pager->options['items_per_page']);
}

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