function AccessPermissionTest::testRenderCaching
Same name in other branches
- 9 core/modules/user/tests/src/Kernel/Views/AccessPermissionTest.php \Drupal\Tests\user\Kernel\Views\AccessPermissionTest::testRenderCaching()
- 8.9.x core/modules/user/tests/src/Kernel/Views/AccessPermissionTest.php \Drupal\Tests\user\Kernel\Views\AccessPermissionTest::testRenderCaching()
- 10 core/modules/user/tests/src/Kernel/Views/AccessPermissionTest.php \Drupal\Tests\user\Kernel\Views\AccessPermissionTest::testRenderCaching()
Tests access on render caching.
File
-
core/
modules/ user/ tests/ src/ Kernel/ Views/ AccessPermissionTest.php, line 90
Class
- AccessPermissionTest
- Tests views perm access plugin.
Namespace
Drupal\Tests\user\Kernel\ViewsCode
public function testRenderCaching() : void {
$view = Views::getView('test_access_perm');
$display =& $view->storage
->getDisplay('default');
$display['display_options']['cache'] = [
'type' => 'tag',
];
$renderer = $this->container
->get('renderer');
$account_switcher = $this->container
->get('account_switcher');
// First access as user without access.
$build = DisplayPluginBase::buildBasicRenderable('test_access_perm', 'default');
$account_switcher->switchTo($this->webUser);
$this->assertEmpty($renderer->renderInIsolation($build));
// Then with access.
$build = DisplayPluginBase::buildBasicRenderable('test_access_perm', 'default');
$account_switcher->switchTo($this->normalUser);
$this->assertNotEmpty($renderer->renderInIsolation($build));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.