You are here

public function CacheTest::testTimeResultCachingWithPager in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/CacheTest.php \Drupal\views\Tests\Plugin\CacheTest::testTimeResultCachingWithPager()

Tests result caching with a pager.

File

core/modules/views/src/Tests/Plugin/CacheTest.php, line 189
Contains \Drupal\views\Tests\Plugin\CacheTest.

Class

CacheTest
Tests pluggable caching for views.

Namespace

Drupal\views\Tests\Plugin

Code

public function testTimeResultCachingWithPager() {
  $view = Views::getView('test_cache');
  $view
    ->setDisplay();
  $view->display_handler
    ->overrideOption('cache', array(
    'type' => 'time',
    'options' => array(
      'results_lifespan' => '3600',
      'output_lifespan' => '3600',
    ),
  ));
  $mapping = [
    'views_test_data_name' => 'name',
  ];
  $view
    ->setDisplay('page_1');
  $view
    ->setCurrentPage(0);
  $this
    ->executeView($view);
  $this
    ->assertIdenticalResultset($view, [
    [
      'name' => 'John',
    ],
    [
      'name' => 'George',
    ],
  ], $mapping);
  $view
    ->destroy();
  $view
    ->setDisplay('page_1');
  $view
    ->setCurrentPage(1);
  $this
    ->executeView($view);
  $this
    ->assertIdenticalResultset($view, [
    [
      'name' => 'Ringo',
    ],
    [
      'name' => 'Paul',
    ],
  ], $mapping);
  $view
    ->destroy();
  $view
    ->setDisplay('page_1');
  $view
    ->setCurrentPage(0);
  $this
    ->executeView($view);
  $this
    ->assertIdenticalResultset($view, [
    [
      'name' => 'John',
    ],
    [
      'name' => 'George',
    ],
  ], $mapping);
  $view
    ->destroy();
  $view
    ->setDisplay('page_1');
  $view
    ->setCurrentPage(2);
  $this
    ->executeView($view);
  $this
    ->assertIdenticalResultset($view, [
    [
      'name' => 'Meredith',
    ],
  ], $mapping);
  $view
    ->destroy();
}