1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of ViewsHandlerFilterStringTest.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Tests the core views_handler_filter_string handler.
|
10 |
|
|
*/
|
11 |
|
|
class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
12 |
|
|
var $column_map = array();
|
13 |
|
|
|
14 |
|
|
public static function getInfo() {
|
15 |
|
|
return array(
|
16 |
|
|
'name' => 'Filter: String',
|
17 |
|
|
'description' => 'Tests the core views_handler_filter_string handler.',
|
18 |
|
|
'group' => 'Views Handlers',
|
19 |
|
|
);
|
20 |
|
|
}
|
21 |
|
|
|
22 |
4003efde
|
Assos Assos
|
/**
|
23 |
|
|
* {@inheritdoc}
|
24 |
|
|
*/
|
25 |
|
|
public function setUp(array $modules = array()) {
|
26 |
|
|
parent::setUp($modules);
|
27 |
|
|
|
28 |
85ad3d82
|
Assos Assos
|
$this->column_map = array(
|
29 |
|
|
'views_test_name' => 'name',
|
30 |
|
|
);
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
function viewsData() {
|
34 |
|
|
$data = parent::viewsData();
|
35 |
|
|
$data['views_test']['name']['filter']['allow empty'] = TRUE;
|
36 |
|
|
$data['views_test']['job']['filter']['allow empty'] = FALSE;
|
37 |
|
|
$data['views_test']['description'] = $data['views_test']['name'];
|
38 |
|
|
|
39 |
|
|
return $data;
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
protected function schemaDefinition() {
|
43 |
|
|
$schema = parent::schemaDefinition();
|
44 |
|
|
$schema['views_test']['fields']['description'] = array(
|
45 |
|
|
'description' => "A person's description",
|
46 |
|
|
'type' => 'text',
|
47 |
|
|
'not null' => FALSE,
|
48 |
|
|
'size' => 'big',
|
49 |
|
|
);
|
50 |
|
|
|
51 |
|
|
return $schema;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
/**
|
55 |
|
|
* An extended test dataset.
|
56 |
|
|
*/
|
57 |
|
|
protected function dataSet() {
|
58 |
|
|
$dataset = parent::dataSet();
|
59 |
|
|
$dataset[0]['description'] = 'John Winston Ono Lennon, MBE (9 October 1940 – 8 December 1980) was an English musician and singer-songwriter who rose to worldwide fame as one of the founding members of The Beatles, one of the most commercially successful and critically acclaimed acts in the history of popular music. Along with fellow Beatle Paul McCartney, he formed one of the most successful songwriting partnerships of the 20th century.';
|
60 |
|
|
$dataset[1]['description'] = 'George Harrison,[1] MBE (25 February 1943 – 29 November 2001)[2] was an English rock guitarist, singer-songwriter, actor and film producer who achieved international fame as lead guitarist of The Beatles.';
|
61 |
|
|
$dataset[2]['description'] = 'Richard Starkey, MBE (born 7 July 1940), better known by his stage name Ringo Starr, is an English musician, singer-songwriter, and actor who gained worldwide fame as the drummer for The Beatles.';
|
62 |
|
|
$dataset[3]['description'] = 'Sir James Paul McCartney, MBE (born 18 June 1942) is an English musician, singer-songwriter and composer. Formerly of The Beatles (1960–1970) and Wings (1971–1981), McCartney is the most commercially successful songwriter in the history of popular music, according to Guinness World Records.[1]';
|
63 |
|
|
$dataset[4]['description'] = NULL;
|
64 |
|
|
|
65 |
|
|
return $dataset;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
protected function getBasicView() {
|
69 |
|
|
$view = parent::getBasicView();
|
70 |
|
|
$view->display['default']->options['fields']['description'] = array(
|
71 |
|
|
'id' => 'description',
|
72 |
|
|
'table' => 'views_test',
|
73 |
|
|
'field' => 'description',
|
74 |
|
|
'relationship' => 'none',
|
75 |
|
|
);
|
76 |
|
|
return $view;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
function testFilterStringEqual() {
|
80 |
|
|
$view = $this->getBasicView();
|
81 |
|
|
|
82 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
83 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
84 |
|
|
'name' => array(
|
85 |
|
|
'id' => 'name',
|
86 |
|
|
'table' => 'views_test',
|
87 |
|
|
'field' => 'name',
|
88 |
|
|
'relationship' => 'none',
|
89 |
|
|
'operator' => '=',
|
90 |
|
|
'value' => 'Ringo',
|
91 |
|
|
),
|
92 |
|
|
));
|
93 |
|
|
|
94 |
|
|
$this->executeView($view);
|
95 |
|
|
$resultset = array(
|
96 |
|
|
array(
|
97 |
|
|
'name' => 'Ringo',
|
98 |
|
|
),
|
99 |
|
|
);
|
100 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
function testFilterStringGroupedExposedEqual() {
|
104 |
|
|
$filters = $this->getGroupedExposedFilters();
|
105 |
|
|
$view = $this->getBasicPageView();
|
106 |
|
|
|
107 |
5d12d676
|
Assos Assos
|
// Filter: Name, Operator: =, Value: Ringo.
|
108 |
85ad3d82
|
Assos Assos
|
$filters['name']['group_info']['default_group'] = 1;
|
109 |
|
|
$view->set_display('page_1');
|
110 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
111 |
|
|
|
112 |
|
|
$this->executeView($view);
|
113 |
|
|
|
114 |
|
|
$resultset = array(
|
115 |
|
|
array(
|
116 |
|
|
'name' => 'Ringo',
|
117 |
|
|
),
|
118 |
|
|
);
|
119 |
|
|
|
120 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
function testFilterStringNotEqual() {
|
124 |
|
|
$view = $this->getBasicView();
|
125 |
|
|
|
126 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
127 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
128 |
|
|
'name' => array(
|
129 |
|
|
'id' => 'name',
|
130 |
|
|
'table' => 'views_test',
|
131 |
|
|
'field' => 'name',
|
132 |
|
|
'relationship' => 'none',
|
133 |
|
|
'operator' => '!=',
|
134 |
|
|
'value' => array('value' => 'Ringo'),
|
135 |
|
|
),
|
136 |
|
|
));
|
137 |
|
|
|
138 |
|
|
$this->executeView($view);
|
139 |
|
|
$resultset = array(
|
140 |
|
|
array(
|
141 |
|
|
'name' => 'John',
|
142 |
|
|
),
|
143 |
|
|
array(
|
144 |
|
|
'name' => 'George',
|
145 |
|
|
),
|
146 |
|
|
array(
|
147 |
|
|
'name' => 'Paul',
|
148 |
|
|
),
|
149 |
|
|
array(
|
150 |
|
|
'name' => 'Meredith',
|
151 |
|
|
),
|
152 |
|
|
);
|
153 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
function testFilterStringGroupedExposedNotEqual() {
|
157 |
|
|
$filters = $this->getGroupedExposedFilters();
|
158 |
|
|
$view = $this->getBasicPageView();
|
159 |
|
|
|
160 |
5d12d676
|
Assos Assos
|
// Filter: Name, Operator: !=, Value: Ringo.
|
161 |
85ad3d82
|
Assos Assos
|
$filters['name']['group_info']['default_group'] = '2';
|
162 |
|
|
|
163 |
|
|
$view->set_display('page_1');
|
164 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
165 |
|
|
|
166 |
|
|
$this->executeView($view);
|
167 |
|
|
|
168 |
|
|
$resultset = array(
|
169 |
|
|
array(
|
170 |
|
|
'name' => 'John',
|
171 |
|
|
),
|
172 |
|
|
array(
|
173 |
|
|
'name' => 'George',
|
174 |
|
|
),
|
175 |
|
|
array(
|
176 |
|
|
'name' => 'Paul',
|
177 |
|
|
),
|
178 |
|
|
array(
|
179 |
|
|
'name' => 'Meredith',
|
180 |
|
|
),
|
181 |
|
|
);
|
182 |
|
|
|
183 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
184 |
|
|
}
|
185 |
|
|
|
186 |
|
|
function testFilterStringContains() {
|
187 |
|
|
$view = $this->getBasicView();
|
188 |
|
|
|
189 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
190 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
191 |
|
|
'name' => array(
|
192 |
|
|
'id' => 'name',
|
193 |
|
|
'table' => 'views_test',
|
194 |
|
|
'field' => 'name',
|
195 |
|
|
'relationship' => 'none',
|
196 |
|
|
'operator' => 'contains',
|
197 |
|
|
'value' => 'ing',
|
198 |
|
|
),
|
199 |
|
|
));
|
200 |
|
|
|
201 |
|
|
$this->executeView($view);
|
202 |
|
|
$resultset = array(
|
203 |
|
|
array(
|
204 |
|
|
'name' => 'Ringo',
|
205 |
|
|
),
|
206 |
|
|
);
|
207 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
function testFilterStringGroupedExposedContains() {
|
212 |
|
|
$filters = $this->getGroupedExposedFilters();
|
213 |
|
|
$view = $this->getBasicPageView();
|
214 |
|
|
|
215 |
5d12d676
|
Assos Assos
|
// Filter: Name, Operator: contains, Value: ing.
|
216 |
85ad3d82
|
Assos Assos
|
$filters['name']['group_info']['default_group'] = '3';
|
217 |
|
|
$view->set_display('page_1');
|
218 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
219 |
|
|
|
220 |
|
|
$this->executeView($view);
|
221 |
|
|
|
222 |
|
|
$resultset = array(
|
223 |
|
|
array(
|
224 |
|
|
'name' => 'Ringo',
|
225 |
|
|
),
|
226 |
|
|
);
|
227 |
|
|
|
228 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
229 |
|
|
}
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
function testFilterStringWord() {
|
233 |
|
|
$view = $this->getBasicView();
|
234 |
|
|
|
235 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
236 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
237 |
|
|
'description' => array(
|
238 |
|
|
'id' => 'description',
|
239 |
|
|
'table' => 'views_test',
|
240 |
|
|
'field' => 'description',
|
241 |
|
|
'relationship' => 'none',
|
242 |
|
|
'operator' => 'word',
|
243 |
|
|
'value' => 'actor',
|
244 |
|
|
),
|
245 |
|
|
));
|
246 |
|
|
|
247 |
|
|
$this->executeView($view);
|
248 |
|
|
$resultset = array(
|
249 |
|
|
array(
|
250 |
|
|
'name' => 'George',
|
251 |
|
|
),
|
252 |
|
|
array(
|
253 |
|
|
'name' => 'Ringo',
|
254 |
|
|
),
|
255 |
|
|
);
|
256 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
257 |
|
|
$view->destroy();
|
258 |
|
|
|
259 |
|
|
$view = $this->getBasicView();
|
260 |
|
|
|
261 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
262 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
263 |
|
|
'description' => array(
|
264 |
|
|
'id' => 'description',
|
265 |
|
|
'table' => 'views_test',
|
266 |
|
|
'field' => 'description',
|
267 |
|
|
'relationship' => 'none',
|
268 |
|
|
'operator' => 'allwords',
|
269 |
|
|
'value' => 'Richard Starkey',
|
270 |
|
|
),
|
271 |
|
|
));
|
272 |
|
|
|
273 |
|
|
$this->executeView($view);
|
274 |
|
|
$resultset = array(
|
275 |
|
|
array(
|
276 |
|
|
'name' => 'Ringo',
|
277 |
|
|
),
|
278 |
|
|
);
|
279 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
function testFilterStringGroupedExposedWord() {
|
284 |
5d12d676
|
Assos Assos
|
$filters = $this->getGroupedExposedFilters();
|
285 |
85ad3d82
|
Assos Assos
|
$view = $this->getBasicPageView();
|
286 |
|
|
|
287 |
5d12d676
|
Assos Assos
|
// Filter: Name, Operator: contains, Value: ing.
|
288 |
85ad3d82
|
Assos Assos
|
$filters['name']['group_info']['default_group'] = '3';
|
289 |
|
|
$view->set_display('page_1');
|
290 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
291 |
|
|
|
292 |
|
|
$this->executeView($view);
|
293 |
|
|
|
294 |
|
|
$resultset = array(
|
295 |
|
|
array(
|
296 |
|
|
'name' => 'Ringo',
|
297 |
|
|
),
|
298 |
|
|
);
|
299 |
|
|
|
300 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
301 |
|
|
$view->destroy();
|
302 |
|
|
|
303 |
|
|
$filters = $this->getGroupedExposedFilters();
|
304 |
|
|
$view = $this->getBasicPageView();
|
305 |
|
|
|
306 |
5d12d676
|
Assos Assos
|
// Filter: Description, Operator: contains, Value: actor.
|
307 |
85ad3d82
|
Assos Assos
|
$filters['description']['group_info']['default_group'] = '1';
|
308 |
|
|
$view->set_display('page_1');
|
309 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
310 |
|
|
|
311 |
|
|
$this->executeView($view);
|
312 |
|
|
$resultset = array(
|
313 |
|
|
array(
|
314 |
|
|
'name' => 'George',
|
315 |
|
|
),
|
316 |
|
|
array(
|
317 |
|
|
'name' => 'Ringo',
|
318 |
|
|
),
|
319 |
|
|
);
|
320 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
function testFilterStringStarts() {
|
324 |
|
|
$view = $this->getBasicView();
|
325 |
|
|
|
326 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
327 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
328 |
|
|
'description' => array(
|
329 |
|
|
'id' => 'description',
|
330 |
|
|
'table' => 'views_test',
|
331 |
|
|
'field' => 'description',
|
332 |
|
|
'relationship' => 'none',
|
333 |
|
|
'operator' => 'starts',
|
334 |
|
|
'value' => 'George',
|
335 |
|
|
),
|
336 |
|
|
));
|
337 |
|
|
|
338 |
|
|
$this->executeView($view);
|
339 |
|
|
$resultset = array(
|
340 |
|
|
array(
|
341 |
|
|
'name' => 'George',
|
342 |
|
|
),
|
343 |
|
|
);
|
344 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
345 |
|
|
}
|
346 |
|
|
|
347 |
|
|
function testFilterStringGroupedExposedStarts() {
|
348 |
|
|
$filters = $this->getGroupedExposedFilters();
|
349 |
|
|
$view = $this->getBasicPageView();
|
350 |
|
|
|
351 |
5d12d676
|
Assos Assos
|
// Filter: Name, Operator: starts, Value: George.
|
352 |
85ad3d82
|
Assos Assos
|
$filters['description']['group_info']['default_group'] = 2;
|
353 |
|
|
$view->set_display('page_1');
|
354 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
355 |
|
|
|
356 |
|
|
$this->executeView($view);
|
357 |
|
|
|
358 |
|
|
$resultset = array(
|
359 |
|
|
array(
|
360 |
|
|
'name' => 'George',
|
361 |
|
|
),
|
362 |
|
|
);
|
363 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
364 |
|
|
}
|
365 |
|
|
|
366 |
|
|
function testFilterStringNotStarts() {
|
367 |
|
|
$view = $this->getBasicView();
|
368 |
|
|
|
369 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
370 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
371 |
|
|
'description' => array(
|
372 |
|
|
'id' => 'description',
|
373 |
|
|
'table' => 'views_test',
|
374 |
|
|
'field' => 'description',
|
375 |
|
|
'relationship' => 'none',
|
376 |
|
|
'operator' => 'not_starts',
|
377 |
|
|
'value' => 'George',
|
378 |
|
|
),
|
379 |
|
|
));
|
380 |
|
|
|
381 |
|
|
$this->executeView($view);
|
382 |
|
|
$resultset = array(
|
383 |
|
|
array(
|
384 |
|
|
'name' => 'John',
|
385 |
|
|
),
|
386 |
|
|
array(
|
387 |
|
|
'name' => 'Ringo',
|
388 |
|
|
),
|
389 |
|
|
array(
|
390 |
|
|
'name' => 'Paul',
|
391 |
|
|
),
|
392 |
5d12d676
|
Assos Assos
|
// There is no Meredith returned because his description is empty.
|
393 |
85ad3d82
|
Assos Assos
|
);
|
394 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
395 |
|
|
}
|
396 |
|
|
|
397 |
|
|
function testFilterStringGroupedExposedNotStarts() {
|
398 |
|
|
$filters = $this->getGroupedExposedFilters();
|
399 |
|
|
$view = $this->getBasicPageView();
|
400 |
|
|
|
401 |
5d12d676
|
Assos Assos
|
// Filter: Name, Operator: not_starts, Value: George.
|
402 |
85ad3d82
|
Assos Assos
|
$filters['description']['group_info']['default_group'] = 3;
|
403 |
|
|
$view->set_display('page_1');
|
404 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
405 |
|
|
|
406 |
|
|
$this->executeView($view);
|
407 |
|
|
|
408 |
|
|
$resultset = array(
|
409 |
|
|
array(
|
410 |
|
|
'name' => 'John',
|
411 |
|
|
),
|
412 |
|
|
array(
|
413 |
|
|
'name' => 'Ringo',
|
414 |
|
|
),
|
415 |
|
|
array(
|
416 |
|
|
'name' => 'Paul',
|
417 |
|
|
),
|
418 |
5d12d676
|
Assos Assos
|
// There is no Meredith returned because his description is empty.
|
419 |
85ad3d82
|
Assos Assos
|
);
|
420 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
421 |
|
|
}
|
422 |
|
|
|
423 |
|
|
function testFilterStringEnds() {
|
424 |
|
|
$view = $this->getBasicView();
|
425 |
|
|
|
426 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
427 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
428 |
|
|
'description' => array(
|
429 |
|
|
'id' => 'description',
|
430 |
|
|
'table' => 'views_test',
|
431 |
|
|
'field' => 'description',
|
432 |
|
|
'relationship' => 'none',
|
433 |
|
|
'operator' => 'ends',
|
434 |
|
|
'value' => 'Beatles.',
|
435 |
|
|
),
|
436 |
|
|
));
|
437 |
|
|
|
438 |
|
|
$this->executeView($view);
|
439 |
|
|
$resultset = array(
|
440 |
|
|
array(
|
441 |
|
|
'name' => 'George',
|
442 |
|
|
),
|
443 |
|
|
array(
|
444 |
|
|
'name' => 'Ringo',
|
445 |
|
|
),
|
446 |
|
|
);
|
447 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
448 |
|
|
}
|
449 |
|
|
|
450 |
|
|
function testFilterStringGroupedExposedEnds() {
|
451 |
|
|
$filters = $this->getGroupedExposedFilters();
|
452 |
|
|
$view = $this->getBasicPageView();
|
453 |
|
|
|
454 |
5d12d676
|
Assos Assos
|
// Filter: Descriptino, Operator: ends, Value: Beatles.
|
455 |
85ad3d82
|
Assos Assos
|
$filters['description']['group_info']['default_group'] = 4;
|
456 |
|
|
$view->set_display('page_1');
|
457 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
458 |
|
|
|
459 |
|
|
$this->executeView($view);
|
460 |
|
|
|
461 |
|
|
$resultset = array(
|
462 |
|
|
array(
|
463 |
|
|
'name' => 'George',
|
464 |
|
|
),
|
465 |
|
|
array(
|
466 |
|
|
'name' => 'Ringo',
|
467 |
|
|
),
|
468 |
|
|
);
|
469 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
470 |
|
|
}
|
471 |
|
|
|
472 |
|
|
function testFilterStringNotEnds() {
|
473 |
|
|
$view = $this->getBasicView();
|
474 |
|
|
|
475 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
476 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
477 |
|
|
'description' => array(
|
478 |
|
|
'id' => 'description',
|
479 |
|
|
'table' => 'views_test',
|
480 |
|
|
'field' => 'description',
|
481 |
|
|
'relationship' => 'none',
|
482 |
|
|
'operator' => 'not_ends',
|
483 |
|
|
'value' => 'Beatles.',
|
484 |
|
|
),
|
485 |
|
|
));
|
486 |
|
|
|
487 |
|
|
$this->executeView($view);
|
488 |
|
|
$resultset = array(
|
489 |
|
|
array(
|
490 |
|
|
'name' => 'John',
|
491 |
|
|
),
|
492 |
|
|
array(
|
493 |
|
|
'name' => 'Paul',
|
494 |
|
|
),
|
495 |
5d12d676
|
Assos Assos
|
// There is no Meredith returned because his description is empty.
|
496 |
85ad3d82
|
Assos Assos
|
);
|
497 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
498 |
|
|
}
|
499 |
|
|
|
500 |
|
|
function testFilterStringGroupedExposedNotEnds() {
|
501 |
|
|
$filters = $this->getGroupedExposedFilters();
|
502 |
|
|
$view = $this->getBasicPageView();
|
503 |
|
|
|
504 |
5d12d676
|
Assos Assos
|
// Filter: Description, Operator: not_ends, Value: Beatles.
|
505 |
85ad3d82
|
Assos Assos
|
$filters['description']['group_info']['default_group'] = 5;
|
506 |
|
|
$view->set_display('page_1');
|
507 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
508 |
|
|
|
509 |
|
|
$this->executeView($view);
|
510 |
|
|
|
511 |
|
|
$resultset = array(
|
512 |
|
|
array(
|
513 |
|
|
'name' => 'John',
|
514 |
|
|
),
|
515 |
|
|
array(
|
516 |
|
|
'name' => 'Paul',
|
517 |
|
|
),
|
518 |
5d12d676
|
Assos Assos
|
// There is no Meredith returned because his description is empty.
|
519 |
85ad3d82
|
Assos Assos
|
);
|
520 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
521 |
|
|
}
|
522 |
|
|
|
523 |
|
|
function testFilterStringNot() {
|
524 |
|
|
$view = $this->getBasicView();
|
525 |
|
|
|
526 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
527 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
528 |
|
|
'description' => array(
|
529 |
|
|
'id' => 'description',
|
530 |
|
|
'table' => 'views_test',
|
531 |
|
|
'field' => 'description',
|
532 |
|
|
'relationship' => 'none',
|
533 |
|
|
'operator' => 'not',
|
534 |
|
|
'value' => 'Beatles.',
|
535 |
|
|
),
|
536 |
|
|
));
|
537 |
|
|
|
538 |
|
|
$this->executeView($view);
|
539 |
|
|
$resultset = array(
|
540 |
|
|
array(
|
541 |
|
|
'name' => 'John',
|
542 |
|
|
),
|
543 |
|
|
array(
|
544 |
|
|
'name' => 'Paul',
|
545 |
|
|
),
|
546 |
5d12d676
|
Assos Assos
|
// There is no Meredith returned because his description is empty.
|
547 |
85ad3d82
|
Assos Assos
|
);
|
548 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
549 |
|
|
}
|
550 |
|
|
|
551 |
|
|
|
552 |
|
|
function testFilterStringGroupedExposedNot() {
|
553 |
|
|
$filters = $this->getGroupedExposedFilters();
|
554 |
|
|
$view = $this->getBasicPageView();
|
555 |
|
|
|
556 |
5d12d676
|
Assos Assos
|
// Filter: Description, Operator: not (does not contains), Value: Beatles.
|
557 |
85ad3d82
|
Assos Assos
|
$filters['description']['group_info']['default_group'] = 6;
|
558 |
|
|
$view->set_display('page_1');
|
559 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
560 |
|
|
|
561 |
|
|
$this->executeView($view);
|
562 |
|
|
|
563 |
|
|
$resultset = array(
|
564 |
|
|
array(
|
565 |
|
|
'name' => 'John',
|
566 |
|
|
),
|
567 |
|
|
array(
|
568 |
|
|
'name' => 'Paul',
|
569 |
|
|
),
|
570 |
5d12d676
|
Assos Assos
|
// There is no Meredith returned because his description is empty.
|
571 |
85ad3d82
|
Assos Assos
|
);
|
572 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
573 |
|
|
|
574 |
|
|
}
|
575 |
|
|
|
576 |
|
|
function testFilterStringShorter() {
|
577 |
|
|
$view = $this->getBasicView();
|
578 |
|
|
|
579 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
580 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
581 |
|
|
'name' => array(
|
582 |
|
|
'id' => 'name',
|
583 |
|
|
'table' => 'views_test',
|
584 |
|
|
'field' => 'name',
|
585 |
|
|
'relationship' => 'none',
|
586 |
|
|
'operator' => 'shorterthan',
|
587 |
|
|
'value' => 5,
|
588 |
|
|
),
|
589 |
|
|
));
|
590 |
|
|
|
591 |
|
|
$this->executeView($view);
|
592 |
|
|
$resultset = array(
|
593 |
|
|
array(
|
594 |
|
|
'name' => 'John',
|
595 |
|
|
),
|
596 |
|
|
array(
|
597 |
|
|
'name' => 'Paul',
|
598 |
|
|
),
|
599 |
|
|
);
|
600 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
601 |
|
|
}
|
602 |
|
|
|
603 |
|
|
function testFilterStringGroupedExposedShorter() {
|
604 |
|
|
$filters = $this->getGroupedExposedFilters();
|
605 |
|
|
$view = $this->getBasicPageView();
|
606 |
|
|
|
607 |
|
|
// Filter: Name, Operator: shorterthan, Value: 5
|
608 |
|
|
$filters['name']['group_info']['default_group'] = 4;
|
609 |
|
|
$view->set_display('page_1');
|
610 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
611 |
|
|
|
612 |
|
|
$this->executeView($view);
|
613 |
|
|
$resultset = array(
|
614 |
|
|
array(
|
615 |
|
|
'name' => 'John',
|
616 |
|
|
),
|
617 |
|
|
array(
|
618 |
|
|
'name' => 'Paul',
|
619 |
|
|
),
|
620 |
|
|
);
|
621 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
622 |
|
|
}
|
623 |
|
|
|
624 |
|
|
function testFilterStringLonger() {
|
625 |
|
|
$view = $this->getBasicView();
|
626 |
|
|
|
627 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
628 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
629 |
|
|
'name' => array(
|
630 |
|
|
'id' => 'name',
|
631 |
|
|
'table' => 'views_test',
|
632 |
|
|
'field' => 'name',
|
633 |
|
|
'relationship' => 'none',
|
634 |
|
|
'operator' => 'longerthan',
|
635 |
|
|
'value' => 7,
|
636 |
|
|
),
|
637 |
|
|
));
|
638 |
|
|
|
639 |
|
|
$this->executeView($view);
|
640 |
|
|
$resultset = array(
|
641 |
|
|
array(
|
642 |
|
|
'name' => 'Meredith',
|
643 |
|
|
),
|
644 |
|
|
);
|
645 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
646 |
|
|
}
|
647 |
|
|
|
648 |
|
|
function testFilterStringGroupedExposedLonger() {
|
649 |
|
|
$filters = $this->getGroupedExposedFilters();
|
650 |
|
|
$view = $this->getBasicPageView();
|
651 |
|
|
|
652 |
|
|
// Filter: Name, Operator: longerthan, Value: 4
|
653 |
|
|
$filters['name']['group_info']['default_group'] = 5;
|
654 |
|
|
$view->set_display('page_1');
|
655 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
656 |
|
|
|
657 |
|
|
$this->executeView($view);
|
658 |
|
|
$resultset = array(
|
659 |
|
|
array(
|
660 |
|
|
'name' => 'Meredith',
|
661 |
|
|
),
|
662 |
|
|
);
|
663 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
664 |
|
|
}
|
665 |
|
|
|
666 |
|
|
|
667 |
|
|
function testFilterStringEmpty() {
|
668 |
|
|
$view = $this->getBasicView();
|
669 |
|
|
|
670 |
5d12d676
|
Assos Assos
|
// Change the filtering.
|
671 |
85ad3d82
|
Assos Assos
|
$view->display['default']->handler->override_option('filters', array(
|
672 |
|
|
'description' => array(
|
673 |
|
|
'id' => 'description',
|
674 |
|
|
'table' => 'views_test',
|
675 |
|
|
'field' => 'description',
|
676 |
|
|
'relationship' => 'none',
|
677 |
|
|
'operator' => 'empty',
|
678 |
|
|
),
|
679 |
|
|
));
|
680 |
|
|
|
681 |
|
|
$this->executeView($view);
|
682 |
|
|
$resultset = array(
|
683 |
|
|
array(
|
684 |
|
|
'name' => 'Meredith',
|
685 |
|
|
),
|
686 |
|
|
);
|
687 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
688 |
|
|
}
|
689 |
|
|
|
690 |
|
|
function testFilterStringGroupedExposedEmpty() {
|
691 |
|
|
$filters = $this->getGroupedExposedFilters();
|
692 |
|
|
$view = $this->getBasicPageView();
|
693 |
|
|
|
694 |
5d12d676
|
Assos Assos
|
// Filter: Description, Operator: empty, Value.
|
695 |
85ad3d82
|
Assos Assos
|
$filters['description']['group_info']['default_group'] = 7;
|
696 |
|
|
$view->set_display('page_1');
|
697 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
698 |
|
|
|
699 |
|
|
$this->executeView($view);
|
700 |
|
|
$resultset = array(
|
701 |
|
|
array(
|
702 |
|
|
'name' => 'Meredith',
|
703 |
|
|
),
|
704 |
|
|
);
|
705 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
706 |
|
|
}
|
707 |
|
|
|
708 |
|
|
protected function getGroupedExposedFilters() {
|
709 |
|
|
$filters = array(
|
710 |
|
|
'name' => array(
|
711 |
|
|
'id' => 'name',
|
712 |
|
|
'table' => 'views_test',
|
713 |
|
|
'field' => 'name',
|
714 |
|
|
'relationship' => 'none',
|
715 |
|
|
'exposed' => TRUE,
|
716 |
|
|
'expose' => array(
|
717 |
|
|
'operator' => 'name_op',
|
718 |
|
|
'label' => 'name',
|
719 |
|
|
'identifier' => 'name',
|
720 |
|
|
),
|
721 |
|
|
'is_grouped' => TRUE,
|
722 |
|
|
'group_info' => array(
|
723 |
|
|
'label' => 'name',
|
724 |
|
|
'identifier' => 'name',
|
725 |
|
|
'default_group' => 'All',
|
726 |
|
|
'group_items' => array(
|
727 |
|
|
1 => array(
|
728 |
|
|
'title' => 'Is Ringo',
|
729 |
|
|
'operator' => '=',
|
730 |
|
|
'value' => 'Ringo',
|
731 |
|
|
),
|
732 |
|
|
2 => array(
|
733 |
|
|
'title' => 'Is not Ringo',
|
734 |
|
|
'operator' => '!=',
|
735 |
|
|
'value' => array('value' => 'Ringo'),
|
736 |
|
|
),
|
737 |
|
|
3 => array(
|
738 |
|
|
'title' => 'Contains ing',
|
739 |
|
|
'operator' => 'contains',
|
740 |
|
|
'value' => 'ing',
|
741 |
|
|
),
|
742 |
|
|
4 => array(
|
743 |
|
|
'title' => 'Shorter than 5 letters',
|
744 |
|
|
'operator' => 'shorterthan',
|
745 |
|
|
'value' => 5,
|
746 |
|
|
),
|
747 |
|
|
5 => array(
|
748 |
|
|
'title' => 'Longer than 7 letters',
|
749 |
|
|
'operator' => 'longerthan',
|
750 |
|
|
'value' => 7,
|
751 |
|
|
),
|
752 |
|
|
),
|
753 |
|
|
),
|
754 |
|
|
),
|
755 |
|
|
'description' => array(
|
756 |
|
|
'id' => 'description',
|
757 |
|
|
'table' => 'views_test',
|
758 |
|
|
'field' => 'description',
|
759 |
|
|
'relationship' => 'none',
|
760 |
|
|
'exposed' => TRUE,
|
761 |
|
|
'expose' => array(
|
762 |
|
|
'operator' => 'description_op',
|
763 |
|
|
'label' => 'description',
|
764 |
|
|
'identifier' => 'description',
|
765 |
|
|
),
|
766 |
|
|
'is_grouped' => TRUE,
|
767 |
|
|
'group_info' => array(
|
768 |
|
|
'label' => 'description',
|
769 |
|
|
'identifier' => 'description',
|
770 |
|
|
'default_group' => 'All',
|
771 |
|
|
'group_items' => array(
|
772 |
|
|
1 => array(
|
773 |
|
|
'title' => 'Contains the word: Actor',
|
774 |
|
|
'operator' => 'word',
|
775 |
|
|
'value' => 'actor',
|
776 |
|
|
),
|
777 |
|
|
2 => array(
|
778 |
|
|
'title' => 'Starts with George',
|
779 |
|
|
'operator' => 'starts',
|
780 |
|
|
'value' => 'George',
|
781 |
|
|
),
|
782 |
|
|
3 => array(
|
783 |
|
|
'title' => 'Not Starts with: George',
|
784 |
|
|
'operator' => 'not_starts',
|
785 |
|
|
'value' => 'George',
|
786 |
|
|
),
|
787 |
|
|
4 => array(
|
788 |
|
|
'title' => 'Ends with: Beatles',
|
789 |
|
|
'operator' => 'ends',
|
790 |
|
|
'value' => 'Beatles.',
|
791 |
|
|
),
|
792 |
|
|
5 => array(
|
793 |
|
|
'title' => 'Not Ends with: Beatles',
|
794 |
|
|
'operator' => 'not_ends',
|
795 |
|
|
'value' => 'Beatles.',
|
796 |
|
|
),
|
797 |
|
|
6 => array(
|
798 |
|
|
'title' => 'Does not contain: Beatles',
|
799 |
|
|
'operator' => 'not',
|
800 |
|
|
'value' => 'Beatles.',
|
801 |
|
|
),
|
802 |
|
|
7 => array(
|
803 |
|
|
'title' => 'Empty description',
|
804 |
|
|
'operator' => 'empty',
|
805 |
|
|
'value' => '',
|
806 |
|
|
),
|
807 |
|
|
),
|
808 |
|
|
),
|
809 |
|
|
),
|
810 |
|
|
);
|
811 |
|
|
return $filters;
|
812 |
|
|
}
|
813 |
|
|
|
814 |
|
|
} |