function ViewsAccessTest::testDynamicAccessPlugin in Views (for Drupal 7) 7.3
Tests dynamic access plugin.
File
- tests/
views_access.test, line 133 - Definition of ViewsAccessTest.
Class
- ViewsAccessTest
- Basic test for pluggable access.
Code
function testDynamicAccessPlugin() {
$view = $this
->view_access_dynamic();
$argument1 = $this
->randomName();
$argument2 = $this
->randomName();
variable_set('test_dynamic_access_argument1', $argument1);
variable_set('test_dynamic_access_argument2', $argument2);
$view
->set_display('default');
$access_plugin = $view->display_handler
->get_plugin('access');
$this
->assertFalse($access_plugin
->access($this->normal_user));
$access_plugin->options['access'] = TRUE;
$this
->assertFalse($access_plugin
->access($this->normal_user));
$view
->set_arguments(array(
$argument1,
$argument2,
));
$this
->assertTrue($access_plugin
->access($this->normal_user));
// FALSE comes from hook_menu caching.
$expected_hook_menu = array(
'views_test_test_dynamic_access_callback',
array(
FALSE,
1,
2,
),
);
$hook_menu = $view
->execute_hook_menu('page_1');
$this
->assertEqual($expected_hook_menu, $hook_menu['test_access_dynamic']['access arguments'][0]);
$expected_hook_menu = array(
'views_test_test_dynamic_access_callback',
array(
TRUE,
1,
2,
),
);
$this
->assertTrue(views_access($expected_hook_menu, $argument1, $argument2));
}