You are here

function AccessTest::testStaticAccessPlugin in Views (for Drupal 7) 8.3

Tests static access check.

See also

Drupal\views_test\Plugin\views\access\StaticTest

File

lib/Drupal/views/Tests/Plugin/AccessTest.php, line 62
Definition of Drupal\views\Tests\Plugin\AccessTest

Class

AccessTest
Basic test for pluggable access.

Namespace

Drupal\views\Tests\Plugin

Code

function testStaticAccessPlugin() {
  $view = $this
    ->createViewFromConfig('test_access_static');
  $access_plugin = $view->display_handler
    ->getPlugin('access');
  $this
    ->assertFalse($access_plugin
    ->access($this->normal_user));
  $access_plugin->options['access'] = TRUE;
  $this
    ->assertTrue($access_plugin
    ->access($this->normal_user));

  // FALSE comes from hook_menu caching.
  $expected_hook_menu = array(
    'views_test_data_test_static_access_callback',
    array(
      FALSE,
    ),
  );
  $hook_menu = $view
    ->executeHookMenu('page_1');
  $this
    ->assertEqual($expected_hook_menu, $hook_menu['test_access_static']['access arguments'][0]);
  $expected_hook_menu = array(
    'views_test_data_test_static_access_callback',
    array(
      TRUE,
    ),
  );
  $this
    ->assertTrue(views_access($expected_hook_menu));
}