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