You are here

protected function ResultTest::setupViewPager in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 123
Contains \Drupal\Tests\views\Unit\Plugin\area\ResultTest.

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
    ->getMockBuilder('Drupal\\views\\Plugin\\views\\pager\\PagerPluginBase')
    ->disableOriginalConstructor()
    ->setMethods(array(
    'getItemsPerPage',
    'getCurrentPage',
  ))
    ->getMock();
  $pager
    ->expects($this
    ->once())
    ->method('getItemsPerPage')
    ->will($this
    ->returnValue($items_per_page));
  $pager
    ->expects($this
    ->once())
    ->method('getCurrentPage')
    ->will($this
    ->returnValue(0));
  $this->view->pager = $pager;
  $this->view->style_plugin = new \stdClass();
  $this->view->total_rows = 100;
  $this->view->result = array(
    1,
    2,
    3,
    4,
    5,
  );
}