function AccessTest::testStaticAccessPlugin

Tests static access check.

See also

Drupal\views_test\Plugin\views\access\StaticTest

File

drupal/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php, line 76
Definition of Drupal\views\Tests\Plugin\AccessTest

Class

AccessTest
Basic test for pluggable access.

Namespace

Drupal\views\Tests\Plugin

Code

function testStaticAccessPlugin() {
  $view = views_get_view('test_access_static');
  $view
    ->setDisplay();
  $access_plugin = $view->display_handler
    ->getPlugin('access');
  $this
    ->assertFalse($access_plugin
    ->access($this->normal_user));
  $this
    ->drupalGet('test_access_static');
  $this
    ->assertResponse(403);
  $display =& $view->storage
    ->getDisplay('default');
  $display['display_options']['access']['options']['access'] = TRUE;
  $access_plugin->options['access'] = TRUE;
  $view
    ->save();
  $this->container
    ->get('router.builder')
    ->rebuild();
  $this
    ->assertTrue($access_plugin
    ->access($this->normal_user));
  $this
    ->drupalGet('test_access_static');
  $this
    ->assertResponse(200);
}