function PagerKernelTest::testSetPagerMethods
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Plugin/PagerKernelTest.php \Drupal\Tests\views\Kernel\Plugin\PagerKernelTest::testSetPagerMethods()
- 8.9.x core/modules/views/tests/src/Kernel/Plugin/PagerKernelTest.php \Drupal\Tests\views\Kernel\Plugin\PagerKernelTest::testSetPagerMethods()
- 11.x core/modules/views/tests/src/Kernel/Plugin/PagerKernelTest.php \Drupal\Tests\views\Kernel\Plugin\PagerKernelTest::testSetPagerMethods()
Tests pager-related setter methods on ViewExecutable.
See also
\Drupal\views\ViewExecutable::setItemsPerPage
\Drupal\views\ViewExecutable::setOffset
\Drupal\views\ViewExecutable::setCurrentPage
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ PagerKernelTest.php, line 45
Class
- PagerKernelTest
- Tests pager-related APIs.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testSetPagerMethods() : void {
$view = Views::getView('test_pager_full');
// Mark the view as cacheable in order have the cache checking working
// below.
$display =& $view->storage
->getDisplay('default');
$display['display_options']['cache']['type'] = 'tag';
$view->storage
->save();
$output = $view->preview();
\Drupal::service('renderer')->renderInIsolation($output);
$this->assertSame(CacheBackendInterface::CACHE_PERMANENT, $output['#cache']['max-age']);
foreach ([
'setItemsPerPage',
'setOffset',
'setCurrentPage',
] as $method) {
$view = Views::getView('test_pager_full');
$view->setDisplay('default');
$view->{$method}(1);
$output = $view->preview();
\Drupal::service('renderer')->renderInIsolation($output);
$this->assertSame(CacheBackendInterface::CACHE_PERMANENT, $output['#cache']['max-age'], 'Max age kept.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.