function CacheTest::testArgumentDefaultCache
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Plugin/CacheTest.php \Drupal\Tests\views\Kernel\Plugin\CacheTest::testArgumentDefaultCache()
- 10 core/modules/views/tests/src/Kernel/Plugin/CacheTest.php \Drupal\Tests\views\Kernel\Plugin\CacheTest::testArgumentDefaultCache()
- 11.x core/modules/views/tests/src/Kernel/Plugin/CacheTest.php \Drupal\Tests\views\Kernel\Plugin\CacheTest::testArgumentDefaultCache()
Tests that cacheability metadata is carried over from argument defaults.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ CacheTest.php, line 389
Class
- CacheTest
- Tests pluggable caching for views.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testArgumentDefaultCache() {
$view = Views::getView('test_view');
// Add a new argument and set the test plugin for the argument_default.
$options = [
'default_argument_type' => 'argument_default_test',
'default_argument_options' => [
'value' => 'John',
],
'default_action' => 'default',
];
$view->addHandler('default', 'argument', 'views_test_data', 'name', $options);
$view->initHandlers();
$output = $view->preview();
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$renderer->renderPlain($output);
$this->assertEquals([
'config:views.view.test_view',
'example_tag',
], $output['#cache']['tags']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.