1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of ViewsPluginDisplayTestCase.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
*
|
10
|
*/
|
11
|
class ViewsPluginDisplayTestCase extends ViewsSqlTest {
|
12
|
|
13
|
/**
|
14
|
*
|
15
|
*/
|
16
|
public static function getInfo() {
|
17
|
return array(
|
18
|
'name' => 'Display plugin',
|
19
|
'description' => 'Tests the basic display plugin.',
|
20
|
'group' => 'Views Plugins',
|
21
|
);
|
22
|
}
|
23
|
|
24
|
/**
|
25
|
* Tests the overriding of filter_groups.
|
26
|
*/
|
27
|
function testFilterGroupsOverriding() {
|
28
|
$view = $this->viewFilterGroupsUpdating();
|
29
|
$view->init_display();
|
30
|
|
31
|
// mark is as overridden, yes FALSE, means overridden.
|
32
|
$view->display['page']->handler->set_override('filter_groups', FALSE);
|
33
|
$this->assertFalse($view->display['page']->handler->is_defaulted('filter_groups'), "Take sure that 'filter_groups' is marked as overridden.");
|
34
|
$this->assertFalse($view->display['page']->handler->is_defaulted('filters'), "Take sure that 'filters'' is marked as overridden.");
|
35
|
}
|
36
|
|
37
|
/**
|
38
|
* Returns a test view for testFilterGroupsOverriding.
|
39
|
*
|
40
|
* @see testFilterGroupsOverriding
|
41
|
*
|
42
|
* @return view
|
43
|
*/
|
44
|
function viewFilterGroupsOverriding() {
|
45
|
$view = new view();
|
46
|
$view->name = 'test_filter_group_override';
|
47
|
$view->description = '';
|
48
|
$view->tag = 'default';
|
49
|
$view->base_table = 'node';
|
50
|
$view->human_name = 'test_filter_group_override';
|
51
|
$view->core = 7;
|
52
|
$view->api_version = '3.0';
|
53
|
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
54
|
|
55
|
/* Display: Master */
|
56
|
$handler = $view->new_display('default', 'Master', 'default');
|
57
|
$handler->display->display_options['access']['type'] = 'perm';
|
58
|
$handler->display->display_options['cache']['type'] = 'none';
|
59
|
$handler->display->display_options['query']['type'] = 'views_query';
|
60
|
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
61
|
$handler->display->display_options['pager']['type'] = 'full';
|
62
|
$handler->display->display_options['style_plugin'] = 'default';
|
63
|
$handler->display->display_options['row_plugin'] = 'fields';
|
64
|
/* Field: Content: Title */
|
65
|
$handler->display->display_options['fields']['title']['id'] = 'title';
|
66
|
$handler->display->display_options['fields']['title']['table'] = 'node';
|
67
|
$handler->display->display_options['fields']['title']['field'] = 'title';
|
68
|
$handler->display->display_options['fields']['title']['label'] = '';
|
69
|
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
|
70
|
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
|
71
|
/* Filter criterion: Content: Published */
|
72
|
$handler->display->display_options['filters']['status']['id'] = 'status';
|
73
|
$handler->display->display_options['filters']['status']['table'] = 'node';
|
74
|
$handler->display->display_options['filters']['status']['field'] = 'status';
|
75
|
$handler->display->display_options['filters']['status']['value'] = 1;
|
76
|
$handler->display->display_options['filters']['status']['group'] = 1;
|
77
|
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
78
|
|
79
|
/* Display: Page */
|
80
|
$handler = $view->new_display('page', 'Page', 'page_1');
|
81
|
$handler->display->display_options['path'] = 'test';
|
82
|
|
83
|
return $view;
|
84
|
}
|
85
|
|
86
|
/**
|
87
|
* Based on a bug some filter_groups landed in the overridden display.
|
88
|
*
|
89
|
* Even the filters weren't overridden.
|
90
|
* This caused multiple issues.
|
91
|
* Take sure that the value from the default display are used.
|
92
|
*
|
93
|
* @see http://drupal.org/node/1259608
|
94
|
* @see views_plugin_display::init()
|
95
|
*/
|
96
|
function testFilterGroupsUpdating() {
|
97
|
$view = $this->viewFilterGroupsUpdating();
|
98
|
$view->init_display();
|
99
|
|
100
|
$this->assertFalse($view->display['page']->handler->options['defaults']['filter_groups']);
|
101
|
$this->assertEqual($view->display['default']->handler->options['filter_groups'], $view->display['page']->handler->options['filter_groups'], 'Take sure the default options are used for the filter_groups');
|
102
|
}
|
103
|
|
104
|
/**
|
105
|
* Returns a test view for testFilterGroupUpdating.
|
106
|
*
|
107
|
* @see testFilterGroupUpdating
|
108
|
*
|
109
|
* @return view
|
110
|
*/
|
111
|
function viewFilterGroupsUpdating() {
|
112
|
$view = new view();
|
113
|
$view->name = 'test_filter_groups';
|
114
|
$view->description = '';
|
115
|
$view->tag = 'default';
|
116
|
$view->base_table = 'node';
|
117
|
$view->human_name = 'test_filter_groups';
|
118
|
$view->core = 7;
|
119
|
$view->api_version = '3.0';
|
120
|
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
121
|
|
122
|
/* Display: Master */
|
123
|
$handler = $view->new_display('default', 'Master', 'default');
|
124
|
$handler->display->display_options['title'] = 'test_filter_groups';
|
125
|
$handler->display->display_options['access']['type'] = 'perm';
|
126
|
$handler->display->display_options['cache']['type'] = 'none';
|
127
|
$handler->display->display_options['query']['type'] = 'views_query';
|
128
|
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
129
|
$handler->display->display_options['pager']['type'] = 'full';
|
130
|
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
|
131
|
$handler->display->display_options['style_plugin'] = 'default';
|
132
|
$handler->display->display_options['row_plugin'] = 'node';
|
133
|
/* Field: Content: Title */
|
134
|
$handler->display->display_options['fields']['title']['id'] = 'title';
|
135
|
$handler->display->display_options['fields']['title']['table'] = 'node';
|
136
|
$handler->display->display_options['fields']['title']['field'] = 'title';
|
137
|
$handler->display->display_options['fields']['title']['label'] = '';
|
138
|
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
|
139
|
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
|
140
|
/* Sort criterion: Content: Post date */
|
141
|
$handler->display->display_options['sorts']['created']['id'] = 'created';
|
142
|
$handler->display->display_options['sorts']['created']['table'] = 'node';
|
143
|
$handler->display->display_options['sorts']['created']['field'] = 'created';
|
144
|
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
|
145
|
$handler->display->display_options['filter_groups']['groups'] = array(
|
146
|
1 => 'AND',
|
147
|
2 => 'AND',
|
148
|
);
|
149
|
/* Filter criterion: Content: Published */
|
150
|
$handler->display->display_options['filters']['status']['id'] = 'status';
|
151
|
$handler->display->display_options['filters']['status']['table'] = 'node';
|
152
|
$handler->display->display_options['filters']['status']['field'] = 'status';
|
153
|
$handler->display->display_options['filters']['status']['value'] = 1;
|
154
|
$handler->display->display_options['filters']['status']['group'] = 1;
|
155
|
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
156
|
/* Filter criterion: Content: Nid */
|
157
|
$handler->display->display_options['filters']['nid']['id'] = 'nid';
|
158
|
$handler->display->display_options['filters']['nid']['table'] = 'node';
|
159
|
$handler->display->display_options['filters']['nid']['field'] = 'nid';
|
160
|
$handler->display->display_options['filters']['nid']['value']['value'] = '1';
|
161
|
$handler->display->display_options['filters']['nid']['group'] = 2;
|
162
|
/* Filter criterion: Content: Nid */
|
163
|
$handler->display->display_options['filters']['nid_1']['id'] = 'nid_1';
|
164
|
$handler->display->display_options['filters']['nid_1']['table'] = 'node';
|
165
|
$handler->display->display_options['filters']['nid_1']['field'] = 'nid';
|
166
|
$handler->display->display_options['filters']['nid_1']['value']['value'] = '2';
|
167
|
$handler->display->display_options['filters']['nid_1']['group'] = 2;
|
168
|
|
169
|
/* Display: Page */
|
170
|
$handler = $view->new_display('page', 'Page', 'page');
|
171
|
$handler->display->display_options['filter_groups']['operator'] = 'OR';
|
172
|
$handler->display->display_options['filter_groups']['groups'] = array(
|
173
|
1 => 'OR',
|
174
|
2 => 'OR',
|
175
|
);
|
176
|
$handler->display->display_options['defaults']['filters'] = FALSE;
|
177
|
/* Filter criterion: Content: Published */
|
178
|
$handler->display->display_options['filters']['status']['id'] = 'status';
|
179
|
$handler->display->display_options['filters']['status']['table'] = 'node';
|
180
|
$handler->display->display_options['filters']['status']['field'] = 'status';
|
181
|
$handler->display->display_options['filters']['status']['value'] = 1;
|
182
|
$handler->display->display_options['filters']['status']['group'] = 1;
|
183
|
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
184
|
/* Filter criterion: Content: Nid */
|
185
|
$handler->display->display_options['filters']['nid']['id'] = 'nid';
|
186
|
$handler->display->display_options['filters']['nid']['table'] = 'node';
|
187
|
$handler->display->display_options['filters']['nid']['field'] = 'nid';
|
188
|
$handler->display->display_options['filters']['nid']['value']['value'] = '1';
|
189
|
$handler->display->display_options['filters']['nid']['group'] = 2;
|
190
|
/* Filter criterion: Content: Nid */
|
191
|
$handler->display->display_options['filters']['nid_1']['id'] = 'nid_1';
|
192
|
$handler->display->display_options['filters']['nid_1']['table'] = 'node';
|
193
|
$handler->display->display_options['filters']['nid_1']['field'] = 'nid';
|
194
|
$handler->display->display_options['filters']['nid_1']['value']['value'] = '2';
|
195
|
$handler->display->display_options['filters']['nid_1']['group'] = 2;
|
196
|
$handler->display->display_options['path'] = 'test-filter-groups';
|
197
|
|
198
|
return $view;
|
199
|
}
|
200
|
|
201
|
}
|