function AccessTest::testDynamicAccessPlugin in Views (for Drupal 7) 8.3
Tests dynamic access plugin.
See also
Drupal\views_test\Plugin\views\access\DyamicTest
File
- lib/
Drupal/ views/ Tests/ Plugin/ AccessTest.php, line 90 - Definition of Drupal\views\Tests\Plugin\AccessTest
Class
- AccessTest
- Basic test for pluggable access.
Namespace
Drupal\views\Tests\PluginCode
function testDynamicAccessPlugin() {
$view = $this
->createViewFromConfig('test_access_dynamic');
$argument1 = $this
->randomName();
$argument2 = $this
->randomName();
variable_set('test_dynamic_access_argument1', $argument1);
variable_set('test_dynamic_access_argument2', $argument2);
$access_plugin = $view->display_handler
->getPlugin('access');
$this
->assertFalse($access_plugin
->access($this->normal_user));
$access_plugin->options['access'] = TRUE;
$this
->assertFalse($access_plugin
->access($this->normal_user));
$view
->setArguments(array(
$argument1,
$argument2,
));
$this
->assertTrue($access_plugin
->access($this->normal_user));
// FALSE comes from hook_menu caching.
$expected_hook_menu = array(
'views_test_data_test_dynamic_access_callback',
array(
FALSE,
1,
2,
),
);
$hook_menu = $view
->executeHookMenu('page_1');
$this
->assertEqual($expected_hook_menu, $hook_menu['test_access_dynamic']['access arguments'][0]);
$expected_hook_menu = array(
'views_test_data_test_dynamic_access_callback',
array(
TRUE,
1,
2,
),
);
$this
->assertTrue(views_access($expected_hook_menu, $argument1, $argument2));
}