public function AccessPermissionTest::testRenderCaching in Drupal 8
Same name and namespace in other branches
- 9 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 89
Class
- AccessPermissionTest
- Tests views perm access plugin.
Namespace
Drupal\Tests\user\Kernel\ViewsCode
public function testRenderCaching() {
$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
->renderPlain($build));
// Then with access.
$build = DisplayPluginBase::buildBasicRenderable('test_access_perm', 'default');
$account_switcher
->switchTo($this->normalUser);
$this
->assertNotEmpty($renderer
->renderPlain($build));
}