Revision 4003efde
Added by Assos Assos over 4 years ago
drupal7/sites/all/modules/views/tests/views_access.test | ||
---|---|---|
20 | 20 |
/** |
21 | 21 |
* {@inheritdoc} |
22 | 22 |
*/ |
23 |
public function setUp() { |
|
24 |
parent::setUp(); |
|
23 |
public function setUp(array $modules = array()) {
|
|
24 |
parent::setUp($modules);
|
|
25 | 25 |
|
26 | 26 |
$this->admin_user = $this->drupalCreateUser(array('access all views')); |
27 | 27 |
$this->web_user = $this->drupalCreateUser(); |
... | ... | |
161 | 161 |
$this->assertTrue(views_access($expected_hook_menu, $argument1, $argument2)); |
162 | 162 |
} |
163 | 163 |
|
164 |
/** |
|
165 |
* Tests access for a view with a missing access plugin. |
|
166 |
*/ |
|
167 |
public function testMissingAccessPlugin() { |
|
168 |
$view = $this->getMissingAccessPluginTestView(); |
|
169 |
|
|
170 |
$view->set_display('default'); |
|
171 |
$access_plugin = $view->display_handler->get_plugin('access'); |
|
172 |
$this->assertFalse($access_plugin); |
|
173 |
|
|
174 |
$this->assertTrue($view->display_handler->access($this->admin_user), t('Admin-Account should be able to access the view everytime')); |
|
175 |
$this->assertTrue($view->display_handler->access($this->web_user)); |
|
176 |
$this->assertTrue($view->display_handler->access($this->normal_user)); |
|
177 |
|
|
178 |
$hook_menu = $view->execute_hook_menu('page_1'); |
|
179 |
$this->assertTrue($hook_menu['test_access_missing']['access arguments'][0]); |
|
180 |
|
|
181 |
$this->assertTrue(views_access(TRUE)); |
|
182 |
} |
|
183 |
|
|
164 | 184 |
function view_access_none() { |
165 | 185 |
$view = new view; |
166 | 186 |
$view->name = 'test_access_none'; |
... | ... | |
285 | 305 |
|
286 | 306 |
return $view; |
287 | 307 |
} |
308 |
|
|
309 |
/** |
|
310 |
* Generates a view with an access plugin that doesn't exist. |
|
311 |
*/ |
|
312 |
protected function getMissingAccessPluginTestView() { |
|
313 |
$view = new view(); |
|
314 |
$view->name = 'test_access_missing'; |
|
315 |
$view->description = ''; |
|
316 |
$view->tag = ''; |
|
317 |
$view->view_php = ''; |
|
318 |
$view->base_table = 'node'; |
|
319 |
$view->is_cacheable = FALSE; |
|
320 |
$view->api_version = 2; |
|
321 |
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ |
|
322 |
|
|
323 |
/* Display: Master */ |
|
324 |
$handler = $view->new_display('default', 'Master', 'default'); |
|
325 |
$handler->display->display_options['access']['type'] = 'does_not_exist'; |
|
326 |
$handler->display->display_options['cache']['type'] = 'none'; |
|
327 |
$handler->display->display_options['exposed_form']['type'] = 'basic'; |
|
328 |
$handler->display->display_options['pager']['type'] = 'full'; |
|
329 |
$handler->display->display_options['style_plugin'] = 'default'; |
|
330 |
$handler->display->display_options['row_plugin'] = 'fields'; |
|
331 |
|
|
332 |
$handler = $view->new_display('page', 'Page', 'page_1'); |
|
333 |
$handler->display->display_options['path'] = 'test_access_missing'; |
|
334 |
|
|
335 |
return $view; |
|
336 |
} |
|
337 |
|
|
288 | 338 |
} |
Also available in: Unified diff
Weekly update of contrib modules