function ResultTest::setupViewPager

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php \Drupal\Tests\views\Unit\Plugin\area\ResultTest::setupViewPager()
  2. 10 core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php \Drupal\Tests\views\Unit\Plugin\area\ResultTest::setupViewPager()
  3. 11.x core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php \Drupal\Tests\views\Unit\Plugin\area\ResultTest::setupViewPager()

Sets up a mock pager on the view executable object.

Parameters

int $items_per_page: The value to return from getItemsPerPage().

1 call to ResultTest::setupViewPager()
ResultTest::testResultArea in core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php
Tests the rendered output of the Result area handler.

File

core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php, line 118

Class

ResultTest
@coversDefaultClass \Drupal\views\Plugin\views\area\Result @group views

Namespace

Drupal\Tests\views\Unit\Plugin\area

Code

protected function setupViewPager($items_per_page = 0) {
    $pager = $this->prophesize(PagerPluginBase::class);
    $pager->getItemsPerPage()
        ->willReturn($items_per_page)
        ->shouldBeCalledTimes(1);
    $pager->getCurrentPage()
        ->willReturn(0)
        ->shouldBeCalledTimes(1);
    $this->view->pager = $pager->reveal();
    $this->view->style_plugin = new \stdClass();
    $this->view->total_rows = 100;
    $this->view->result = [
        1,
        2,
        3,
        4,
        5,
    ];
}

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