public function PagerKernelTest::testSetPagerMethods in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/Plugin/PagerKernelTest.php \Drupal\views\Tests\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/ src/ Tests/ Plugin/ PagerKernelTest.php, line 48 - Contains \Drupal\views\Tests\Plugin\PagerKernelTest.
Class
- PagerKernelTest
- Tests pager-related APIs.
Namespace
Drupal\views\Tests\PluginCode
public function testSetPagerMethods() {
$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')
->renderPlain($output);
$this
->assertIdentical(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')
->renderPlain($output);
$this
->assertIdentical(CacheBackendInterface::CACHE_PERMANENT, $output['#cache']['max-age'], 'Max age kept.');
}
}