function AccessTest::testStaticAccessPlugin
Same name in other branches
- 9 core/modules/views/tests/src/Functional/Plugin/AccessTest.php \Drupal\Tests\views\Functional\Plugin\AccessTest::testStaticAccessPlugin()
- 10 core/modules/views/tests/src/Functional/Plugin/AccessTest.php \Drupal\Tests\views\Functional\Plugin\AccessTest::testStaticAccessPlugin()
- 11.x core/modules/views/tests/src/Functional/Plugin/AccessTest.php \Drupal\Tests\views\Functional\Plugin\AccessTest::testStaticAccessPlugin()
Tests static access check.
See also
\Drupal\views_test\Plugin\views\access\StaticTest
File
-
core/
modules/ views/ tests/ src/ Functional/ Plugin/ AccessTest.php, line 89
Class
- AccessTest
- Tests pluggable access for views.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testStaticAccessPlugin() {
$view = Views::getView('test_access_static');
$view->setDisplay();
$access_plugin = $view->display_handler
->getPlugin('access');
$this->assertFalse($access_plugin->access($this->normalUser));
$this->drupalGet('test_access_static');
$this->assertSession()
->statusCodeEquals(403);
$display =& $view->storage
->getDisplay('default');
$display['display_options']['access']['options']['access'] = TRUE;
$access_plugin->options['access'] = TRUE;
$view->save();
// Saving a view will cause the router to be rebuilt when the kernel
// termination event fires. Simulate that here.
$this->container
->get('router.builder')
->rebuildIfNeeded();
$this->assertTrue($access_plugin->access($this->normalUser));
$this->drupalGet('test_access_static');
$this->assertSession()
->statusCodeEquals(200);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.