1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of ViewsHandlerFilterCombineTest.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Tests the combine filter handler.
|
10 |
|
|
*/
|
11 |
|
|
class ViewsHandlerFilterCombineTest extends ViewsSqlTest {
|
12 |
|
|
var $column_map = array();
|
13 |
|
|
|
14 |
|
|
public static function getInfo() {
|
15 |
|
|
return array(
|
16 |
|
|
'name' => 'Filter: Combine',
|
17 |
|
|
'description' => 'Tests the combine filter handler.',
|
18 |
|
|
'group' => 'Views Handlers',
|
19 |
|
|
);
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
function setUp() {
|
23 |
|
|
parent::setUp();
|
24 |
|
|
$this->column_map = array(
|
25 |
|
|
'views_test_name' => 'name',
|
26 |
|
|
'views_test_job' => 'job',
|
27 |
|
|
);
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
protected function getBasicView() {
|
31 |
|
|
$view = parent::getBasicView();
|
32 |
|
|
$fields = $view->display['default']->handler->options['fields'];
|
33 |
|
|
$view->display['default']->display_options['fields']['job'] = array(
|
34 |
|
|
'id' => 'job',
|
35 |
|
|
'table' => 'views_test',
|
36 |
|
|
'field' => 'job',
|
37 |
|
|
'relationship' => 'none',
|
38 |
|
|
);
|
39 |
|
|
return $view;
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
public function testFilterCombineContains() {
|
43 |
|
|
$view = $this->getBasicView();
|
44 |
|
|
|
45 |
|
|
// Change the filtering.
|
46 |
|
|
$view->display['default']->handler->override_option('filters', array(
|
47 |
|
|
'age' => array(
|
48 |
|
|
'id' => 'combine',
|
49 |
|
|
'table' => 'views',
|
50 |
|
|
'field' => 'combine',
|
51 |
|
|
'relationship' => 'none',
|
52 |
|
|
'operator' => 'contains',
|
53 |
|
|
'fields' => array(
|
54 |
|
|
'name',
|
55 |
|
|
'job',
|
56 |
|
|
),
|
57 |
|
|
'value' => 'ing',
|
58 |
|
|
),
|
59 |
|
|
));
|
60 |
|
|
|
61 |
|
|
$this->executeView($view);
|
62 |
|
|
$resultset = array(
|
63 |
|
|
array(
|
64 |
|
|
'name' => 'John',
|
65 |
|
|
'job' => 'Singer',
|
66 |
|
|
),
|
67 |
|
|
array(
|
68 |
|
|
'name' => 'George',
|
69 |
|
|
'job' => 'Singer',
|
70 |
|
|
),
|
71 |
|
|
array(
|
72 |
|
|
'name' => 'Ringo',
|
73 |
|
|
'job' => 'Drummer',
|
74 |
|
|
),
|
75 |
|
|
array(
|
76 |
|
|
'name' => 'Ginger',
|
77 |
|
|
'job' => NULL,
|
78 |
|
|
),
|
79 |
|
|
);
|
80 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
/**
|
84 |
|
|
* Additional data to test the NULL issue.
|
85 |
|
|
*/
|
86 |
|
|
protected function dataSet() {
|
87 |
|
|
$data_set = parent::dataSet();
|
88 |
|
|
$data_set[] = array(
|
89 |
|
|
'name' => 'Ginger',
|
90 |
|
|
'age' => 25,
|
91 |
|
|
'job' => NULL,
|
92 |
|
|
'created' => gmmktime(0, 0, 0, 1, 2, 2000),
|
93 |
|
|
);
|
94 |
|
|
return $data_set;
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
/**
|
98 |
|
|
* Allow {views_test}.job to be NULL.
|
99 |
|
|
*/
|
100 |
|
|
protected function schemaDefinition() {
|
101 |
|
|
$schema = parent::schemaDefinition();
|
102 |
|
|
unset($schema['views_test']['fields']['job']['not null']);
|
103 |
|
|
return $schema;
|
104 |
|
|
}
|
105 |
|
|
} |