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