1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of ViewsHandlerFilterEqualityTest.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Tests the core views_handler_filter_equality handler.
|
10 |
|
|
*/
|
11 |
|
|
class ViewsHandlerFilterEqualityTest extends ViewsSqlTest {
|
12 |
|
|
public static function getInfo() {
|
13 |
|
|
return array(
|
14 |
|
|
'name' => 'Filter: Equality',
|
15 |
|
|
'description' => 'Test the core views_handler_filter_equality handler.',
|
16 |
|
|
'group' => 'Views Handlers',
|
17 |
|
|
);
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
function setUp() {
|
21 |
|
|
parent::setUp();
|
22 |
|
|
$this->column_map = array(
|
23 |
|
|
'views_test_name' => 'name',
|
24 |
|
|
);
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
function viewsData() {
|
28 |
|
|
$data = parent::viewsData();
|
29 |
|
|
$data['views_test']['name']['filter']['handler'] = 'views_handler_filter_equality';
|
30 |
|
|
|
31 |
|
|
return $data;
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
function testEqual() {
|
35 |
|
|
$view = $this->getBasicView();
|
36 |
|
|
|
37 |
|
|
// Change the filtering
|
38 |
|
|
$view->display['default']->handler->override_option('filters', array(
|
39 |
|
|
'name' => array(
|
40 |
|
|
'id' => 'name',
|
41 |
|
|
'table' => 'views_test',
|
42 |
|
|
'field' => 'name',
|
43 |
|
|
'relationship' => 'none',
|
44 |
|
|
'operator' => '=',
|
45 |
|
|
'value' => array('value' => 'Ringo'),
|
46 |
|
|
),
|
47 |
|
|
));
|
48 |
|
|
|
49 |
|
|
$this->executeView($view);
|
50 |
|
|
$resultset = array(
|
51 |
|
|
array(
|
52 |
|
|
'name' => 'Ringo',
|
53 |
|
|
),
|
54 |
|
|
);
|
55 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
public function testEqualGroupedExposed() {
|
59 |
|
|
$filters = $this->getGroupedExposedFilters();
|
60 |
|
|
$view = $this->getBasicPageView();
|
61 |
|
|
|
62 |
|
|
// Filter: Name, Operator: =, Value: Ringo
|
63 |
|
|
$filters['name']['group_info']['default_group'] = 1;
|
64 |
|
|
$view->set_display('page_1');
|
65 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
66 |
|
|
|
67 |
|
|
$this->executeView($view);
|
68 |
|
|
$resultset = array(
|
69 |
|
|
array(
|
70 |
|
|
'name' => 'Ringo',
|
71 |
|
|
),
|
72 |
|
|
);
|
73 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
function testNotEqual() {
|
77 |
|
|
$view = $this->getBasicView();
|
78 |
|
|
|
79 |
|
|
// Change the filtering
|
80 |
|
|
$view->display['default']->handler->override_option('filters', array(
|
81 |
|
|
'name' => array(
|
82 |
|
|
'id' => 'name',
|
83 |
|
|
'table' => 'views_test',
|
84 |
|
|
'field' => 'name',
|
85 |
|
|
'relationship' => 'none',
|
86 |
|
|
'operator' => '!=',
|
87 |
|
|
'value' => array('value' => 'Ringo'),
|
88 |
|
|
),
|
89 |
|
|
));
|
90 |
|
|
|
91 |
|
|
$this->executeView($view);
|
92 |
|
|
$resultset = array(
|
93 |
|
|
array(
|
94 |
|
|
'name' => 'John',
|
95 |
|
|
),
|
96 |
|
|
array(
|
97 |
|
|
'name' => 'George',
|
98 |
|
|
),
|
99 |
|
|
array(
|
100 |
|
|
'name' => 'Paul',
|
101 |
|
|
),
|
102 |
|
|
array(
|
103 |
|
|
'name' => 'Meredith',
|
104 |
|
|
),
|
105 |
|
|
);
|
106 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
public function testEqualGroupedNotExposed() {
|
110 |
|
|
$filters = $this->getGroupedExposedFilters();
|
111 |
|
|
$view = $this->getBasicPageView();
|
112 |
|
|
|
113 |
|
|
// Filter: Name, Operator: !=, Value: Ringo
|
114 |
|
|
$filters['name']['group_info']['default_group'] = 2;
|
115 |
|
|
$view->set_display('page_1');
|
116 |
|
|
$view->display['page_1']->handler->override_option('filters', $filters);
|
117 |
|
|
|
118 |
|
|
$this->executeView($view);
|
119 |
|
|
$resultset = array(
|
120 |
|
|
array(
|
121 |
|
|
'name' => 'John',
|
122 |
|
|
),
|
123 |
|
|
array(
|
124 |
|
|
'name' => 'George',
|
125 |
|
|
),
|
126 |
|
|
array(
|
127 |
|
|
'name' => 'Paul',
|
128 |
|
|
),
|
129 |
|
|
array(
|
130 |
|
|
'name' => 'Meredith',
|
131 |
|
|
),
|
132 |
|
|
);
|
133 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
protected function getGroupedExposedFilters() {
|
138 |
|
|
$filters = array(
|
139 |
|
|
'name' => array(
|
140 |
|
|
'id' => 'name',
|
141 |
|
|
'table' => 'views_test',
|
142 |
|
|
'field' => 'name',
|
143 |
|
|
'relationship' => 'none',
|
144 |
|
|
'exposed' => TRUE,
|
145 |
|
|
'expose' => array(
|
146 |
|
|
'operator' => 'name_op',
|
147 |
|
|
'label' => 'name',
|
148 |
|
|
'identifier' => 'name',
|
149 |
|
|
),
|
150 |
|
|
'is_grouped' => TRUE,
|
151 |
|
|
'group_info' => array(
|
152 |
|
|
'label' => 'name',
|
153 |
|
|
'identifier' => 'name',
|
154 |
|
|
'default_group' => 'All',
|
155 |
|
|
'group_items' => array(
|
156 |
|
|
1 => array(
|
157 |
|
|
'title' => 'Name is equal to Ringo',
|
158 |
|
|
'operator' => '=',
|
159 |
|
|
'value' => array('value' => 'Ringo'),
|
160 |
|
|
),
|
161 |
|
|
2 => array(
|
162 |
|
|
'title' => 'Name is not equal to Ringo',
|
163 |
|
|
'operator' => '!=',
|
164 |
|
|
'value' => array('value' => 'Ringo'),
|
165 |
|
|
),
|
166 |
|
|
),
|
167 |
|
|
),
|
168 |
|
|
),
|
169 |
|
|
);
|
170 |
|
|
return $filters;
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
} |