1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of ViewsUserArgumentDefault.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Tests views user argument default plugin.
|
10 |
|
|
*/
|
11 |
|
|
class ViewsUserArgumentDefault extends ViewsSqlTest {
|
12 |
|
|
public static function getInfo() {
|
13 |
|
|
return array(
|
14 |
|
|
'name' => 'Tests user argument default plugin',
|
15 |
|
|
'description' => 'Tests user argument default plugin',
|
16 |
|
|
'group' => 'Views Plugins',
|
17 |
|
|
);
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
public function test_plugin_argument_default_current_user() {
|
21 |
|
|
// Create a user to test.
|
22 |
|
|
$account = $this->drupalCreateUser();
|
23 |
|
|
|
24 |
|
|
// Switch the user, we have to check the global user too, because drupalLogin is only for the simpletest browser.
|
25 |
|
|
$this->drupalLogin($account);
|
26 |
|
|
global $user;
|
27 |
|
|
$admin = $user;
|
28 |
|
|
drupal_save_session(FALSE);
|
29 |
|
|
$user = $account;
|
30 |
|
|
|
31 |
|
|
$view = $this->view_plugin_argument_default_current_user();
|
32 |
|
|
|
33 |
|
|
$view->set_display('default');
|
34 |
|
|
$view->pre_execute();
|
35 |
|
|
$view->init_handlers();
|
36 |
|
|
|
37 |
|
|
$this->assertEqual($view->argument['null']->get_default_argument(), $account->uid, 'Uid of the current user is used.');
|
38 |
|
|
// Switch back.
|
39 |
|
|
$user = $admin;
|
40 |
|
|
drupal_save_session(TRUE);
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
function view_plugin_argument_default_current_user() {
|
44 |
|
|
$view = new view;
|
45 |
|
|
$view->name = 'test_plugin_argument_default_current_user';
|
46 |
|
|
$view->description = '';
|
47 |
|
|
$view->tag = '';
|
48 |
|
|
$view->view_php = '';
|
49 |
|
|
$view->base_table = 'node';
|
50 |
|
|
$view->is_cacheable = FALSE;
|
51 |
|
|
$view->api_version = '3.0-alpha1';
|
52 |
|
|
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
53 |
|
|
|
54 |
|
|
/* Display: Master */
|
55 |
|
|
$handler = $view->new_display('default', 'Master', 'default');
|
56 |
|
|
$handler->display->display_options['access']['type'] = 'none';
|
57 |
|
|
$handler->display->display_options['cache']['type'] = 'none';
|
58 |
|
|
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
59 |
|
|
$handler->display->display_options['pager']['type'] = 'full';
|
60 |
|
|
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
|
61 |
|
|
$handler->display->display_options['pager']['options']['offset'] = '0';
|
62 |
|
|
$handler->display->display_options['pager']['options']['id'] = '0';
|
63 |
|
|
$handler->display->display_options['style_plugin'] = 'default';
|
64 |
|
|
$handler->display->display_options['row_plugin'] = 'fields';
|
65 |
|
|
/* Field: Content: Title */
|
66 |
|
|
$handler->display->display_options['fields']['title']['id'] = 'title';
|
67 |
|
|
$handler->display->display_options['fields']['title']['table'] = 'node';
|
68 |
|
|
$handler->display->display_options['fields']['title']['field'] = 'title';
|
69 |
|
|
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
|
70 |
|
|
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
|
71 |
|
|
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
|
72 |
|
|
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
|
73 |
|
|
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
|
74 |
|
|
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
|
75 |
|
|
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
|
76 |
|
|
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
|
77 |
|
|
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
|
78 |
|
|
$handler->display->display_options['fields']['title']['link_to_node'] = 0;
|
79 |
|
|
/* Argument: Global: Null */
|
80 |
|
|
$handler->display->display_options['arguments']['null']['id'] = 'null';
|
81 |
|
|
$handler->display->display_options['arguments']['null']['table'] = 'views';
|
82 |
|
|
$handler->display->display_options['arguments']['null']['field'] = 'null';
|
83 |
|
|
$handler->display->display_options['arguments']['null']['default_action'] = 'default';
|
84 |
|
|
$handler->display->display_options['arguments']['null']['style_plugin'] = 'default_summary';
|
85 |
|
|
$handler->display->display_options['arguments']['null']['default_argument_type'] = 'current_user';
|
86 |
|
|
$handler->display->display_options['arguments']['null']['must_not_be'] = 0;
|
87 |
|
|
|
88 |
|
|
return $view;
|
89 |
|
|
}
|
90 |
|
|
} |