Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | ||
3 | /** | |
4 | * File for the CRM_Contact_Form_Search_Custom_GroupTestDataProvider class | |
5 | * | |
6 | * (PHP 5) | |
7 | * | |
6c6e6187 TO |
8 | * @author Walt Haas <walt@dharmatech.org> (801) 534-1262 |
9 | * @copyright Copyright CiviCRM LLC (C) 2009 | |
10 | * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html | |
6a488035 | 11 | * GNU Affero General Public License version 3 |
6c6e6187 TO |
12 | * @version $Id: GroupTestDataProvider.php 44314 2012-12-19 11:12:49Z kurund $ |
13 | * @package CiviCRM | |
6a488035 TO |
14 | * |
15 | * This file is part of CiviCRM | |
16 | * | |
17 | * CiviCRM is free software; you can redistribute it and/or | |
18 | * modify it under the terms of the GNU Affero General Public License | |
19 | * as published by the Free Software Foundation; either version 3 of | |
20 | * the License, or (at your option) any later version. | |
21 | * | |
22 | * CiviCRM is distributed in the hope that it will be useful, | |
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | * GNU Affero General Public License for more details. | |
26 | * | |
27 | * You should have received a copy of the GNU Affero General Public | |
28 | * License along with this program. If not, see | |
29 | * <http://www.gnu.org/licenses/>. | |
30 | */ | |
31 | ||
32 | /** | |
33 | * Provide data to the CRM_Contact_Form_Search_Custom_GroupTest class | |
34 | * | |
6c6e6187 | 35 | * @package CiviCRM |
6a488035 TO |
36 | */ |
37 | class CRM_Contact_Form_Search_Custom_GroupTestDataProvider implements Iterator { | |
38 | ||
39 | /** | |
6c6e6187 | 40 | * @var integer |
6a488035 TO |
41 | */ |
42 | private $i = 0; | |
43 | ||
44 | /** | |
6c6e6187 | 45 | * @var mixed[] |
6a488035 TO |
46 | * This dataset describes various form values and what contact |
47 | * IDs should be selected when the form values are applied to the | |
48 | * database in dataset.xml | |
49 | */ | |
50 | private $dataset = array( | |
51 | // Exclude static group 3 | |
6c6e6187 | 52 | array( |
92915c55 | 53 | 'fv' => array('excludeGroups' => array('3')), |
6a488035 | 54 | 'id' => array( |
92915c55 TO |
55 | '9', |
56 | '10', | |
57 | '11', | |
58 | '12', | |
59 | '13', | |
60 | '14', | |
61 | '15', | |
62 | '16', | |
63 | '26', | |
6a488035 TO |
64 | ), |
65 | ), | |
66 | // Include static group 3 | |
6c6e6187 | 67 | array( |
92915c55 | 68 | 'fv' => array('includeGroups' => array('3')), |
6a488035 | 69 | 'id' => array( |
92915c55 TO |
70 | '17', |
71 | '18', | |
72 | '19', | |
73 | '20', | |
74 | '21', | |
75 | '22', | |
76 | '23', | |
77 | '24', | |
78 | '27', | |
79 | '28', | |
6a488035 TO |
80 | ), |
81 | ), | |
82 | // Include static group 5 | |
6c6e6187 | 83 | array( |
92915c55 | 84 | 'fv' => array('includeGroups' => array('5')), |
6a488035 | 85 | 'id' => array( |
92915c55 TO |
86 | '13', |
87 | '14', | |
88 | '15', | |
89 | '16', | |
90 | '21', | |
91 | '22', | |
92 | '23', | |
93 | '24', | |
6a488035 TO |
94 | ), |
95 | ), | |
96 | // Include static groups 3 and 5 | |
6c6e6187 | 97 | array( |
92915c55 | 98 | 'fv' => array('includeGroups' => array('3', '5')), |
6a488035 | 99 | 'id' => array( |
92915c55 TO |
100 | '13', |
101 | '14', | |
102 | '15', | |
103 | '16', | |
104 | '17', | |
105 | '18', | |
106 | '19', | |
107 | '20', | |
108 | '21', | |
109 | '22', | |
110 | '23', | |
111 | '24', | |
112 | '27', | |
113 | '28', | |
6a488035 TO |
114 | ), |
115 | ), | |
116 | // Include static group 3, exclude static group 5 | |
6c6e6187 | 117 | array( |
92915c55 TO |
118 | 'fv' => array( |
119 | 'includeGroups' => array('3'), | |
6a488035 TO |
120 | 'excludeGroups' => array('5'), |
121 | ), | |
122 | 'id' => array('17', '18', '19', '20', '27', '28'), | |
123 | ), | |
124 | // Exclude tag 7 | |
6c6e6187 | 125 | array( |
92915c55 | 126 | 'fv' => array('excludeTags' => array('7')), |
6a488035 | 127 | 'id' => array( |
92915c55 TO |
128 | '9', |
129 | '10', | |
130 | '13', | |
131 | '14', | |
132 | '17', | |
133 | '18', | |
134 | '21', | |
135 | '22', | |
136 | '27', | |
6a488035 TO |
137 | ), |
138 | ), | |
139 | // Include tag 7 | |
6c6e6187 | 140 | array( |
92915c55 | 141 | 'fv' => array('includeTags' => array('7')), |
6a488035 | 142 | 'id' => array( |
92915c55 TO |
143 | '11', |
144 | '12', | |
145 | '15', | |
146 | '16', | |
147 | '19', | |
148 | '20', | |
149 | '23', | |
150 | '24', | |
151 | '26', | |
152 | '28', | |
6a488035 TO |
153 | ), |
154 | ), | |
155 | // Include tag 9 | |
6c6e6187 | 156 | array( |
92915c55 | 157 | 'fv' => array('includeTags' => array('9')), |
6a488035 | 158 | 'id' => array( |
92915c55 TO |
159 | '10', |
160 | '12', | |
161 | '14', | |
162 | '16', | |
163 | '18', | |
164 | '20', | |
165 | '22', | |
166 | '24', | |
6a488035 TO |
167 | ), |
168 | ), | |
169 | // Include tags 7 and 9 | |
6c6e6187 | 170 | array( |
92915c55 | 171 | 'fv' => array('includeTags' => array('7', '9')), |
6a488035 | 172 | 'id' => array( |
92915c55 TO |
173 | '10', |
174 | '11', | |
175 | '12', | |
176 | '14', | |
177 | '15', | |
178 | '16', | |
179 | '18', | |
180 | '19', | |
181 | '20', | |
182 | '22', | |
183 | '23', | |
184 | '24', | |
185 | '26', | |
186 | '28', | |
6a488035 TO |
187 | ), |
188 | ), | |
189 | // Include tag 7, exclude tag 9 | |
6c6e6187 | 190 | array( |
92915c55 TO |
191 | 'fv' => array( |
192 | 'includeTags' => array('7'), | |
6a488035 TO |
193 | 'excludeTags' => array('9'), |
194 | ), | |
195 | 'id' => array('11', '15', '19', '23', '26', '28'), | |
196 | ), | |
197 | // Include static group 3, include tag 7 (either) | |
198 | array( | |
199 | 'fv' => array( | |
200 | 'includeGroups' => array('3'), | |
201 | 'includeTags' => array('7'), | |
202 | 'andOr' => 0, | |
203 | ), | |
204 | 'id' => array( | |
92915c55 TO |
205 | '11', |
206 | '12', | |
207 | '15', | |
208 | '16', | |
209 | '17', | |
210 | '18', | |
211 | '19', | |
212 | '20', | |
213 | '21', | |
214 | '22', | |
215 | '23', | |
216 | '24', | |
217 | '26', | |
218 | '27', | |
219 | '28', | |
6a488035 TO |
220 | ), |
221 | ), | |
222 | // Include static group 3, include tag 7 (both) | |
223 | array( | |
224 | 'fv' => array( | |
225 | 'includeGroups' => array('3'), | |
226 | 'includeTags' => array('7'), | |
227 | 'andOr' => 1, | |
228 | ), | |
229 | 'id' => array('19', '20', '23', '24', '28'), | |
230 | ), | |
231 | // Include static group 3, exclude tag 7 | |
6c6e6187 | 232 | array( |
92915c55 TO |
233 | 'fv' => array( |
234 | 'includeGroups' => array('3'), | |
6a488035 TO |
235 | 'excludeTags' => array('7'), |
236 | ), | |
237 | 'id' => array('17', '18', '21', '22', '27'), | |
238 | ), | |
239 | // Include tag 9, exclude static group 5 | |
6c6e6187 | 240 | array( |
92915c55 TO |
241 | 'fv' => array( |
242 | 'includeTags' => array('9'), | |
6a488035 TO |
243 | 'excludeGroups' => array('5'), |
244 | ), | |
6c6e6187 | 245 | 'id' => array('10', '12', '18', '20'), |
6a488035 TO |
246 | ), |
247 | // Exclude tag 9, exclude static group 5 | |
6c6e6187 | 248 | array( |
92915c55 TO |
249 | 'fv' => array( |
250 | 'excludeTags' => array('9'), | |
6a488035 TO |
251 | 'excludeGroups' => array('5'), |
252 | ), | |
253 | 'id' => array( | |
92915c55 TO |
254 | '9', |
255 | '11', | |
256 | '17', | |
257 | '19', | |
258 | '26', | |
259 | '27', | |
260 | '28', | |
6a488035 TO |
261 | ), |
262 | ), | |
263 | // Include smart group 6 | |
6c6e6187 | 264 | array( |
92915c55 | 265 | 'fv' => array('includeGroups' => array('6')), |
6a488035 | 266 | 'id' => array( |
92915c55 TO |
267 | '9', |
268 | '10', | |
269 | '11', | |
270 | '12', | |
271 | '13', | |
272 | '14', | |
273 | '15', | |
274 | '16', | |
275 | '26', | |
6a488035 TO |
276 | ), |
277 | ), | |
278 | // Include smart group 4 | |
6c6e6187 | 279 | array( |
92915c55 | 280 | 'fv' => array('includeGroups' => array('4')), |
6a488035 | 281 | 'id' => array( |
92915c55 TO |
282 | '17', |
283 | '18', | |
284 | '19', | |
285 | '20', | |
286 | '21', | |
287 | '22', | |
288 | '23', | |
289 | '24', | |
290 | '27', | |
291 | '28', | |
6a488035 TO |
292 | ), |
293 | ), | |
294 | // Include smart group 4 and static group 5 | |
6c6e6187 | 295 | array( |
92915c55 | 296 | 'fv' => array('includeGroups' => array('4', '5')), |
6a488035 | 297 | 'id' => array( |
92915c55 TO |
298 | '13', |
299 | '14', | |
300 | '15', | |
301 | '16', | |
302 | '17', | |
303 | '18', | |
304 | '19', | |
305 | '20', | |
306 | '21', | |
307 | '22', | |
308 | '23', | |
309 | '24', | |
310 | '27', | |
311 | '28', | |
6a488035 TO |
312 | ), |
313 | ), | |
314 | ); | |
315 | ||
316 | public function _construct() { | |
317 | $this->i = 0; | |
318 | } | |
319 | ||
320 | public function rewind() { | |
321 | $this->i = 0; | |
322 | } | |
323 | ||
4cbe18b8 EM |
324 | /** |
325 | * @return array | |
326 | */ | |
6a488035 TO |
327 | public function current() { |
328 | $count = count($this->dataset[$this->i]['id']); | |
92915c55 TO |
329 | $ids = $this->dataset[$this->i]['id']; |
330 | $full = array(); | |
6a488035 TO |
331 | foreach ($this->dataset[$this->i]['id'] as $key => $value) { |
332 | $full[] = array( | |
333 | 'contact_id' => $value, | |
334 | 'contact_type' => 'Individual', | |
335 | 'sort_name' => "Test Contact $value", | |
336 | ); | |
337 | } | |
338 | return array($this->dataset[$this->i]['fv'], $count, $ids, $full); | |
339 | } | |
340 | ||
4cbe18b8 EM |
341 | /** |
342 | * @return int | |
343 | */ | |
6a488035 TO |
344 | public function key() { |
345 | return $this->i; | |
346 | } | |
347 | ||
348 | public function next() { | |
349 | $this->i++; | |
350 | } | |
351 | ||
4cbe18b8 EM |
352 | /** |
353 | * @return bool | |
354 | */ | |
6a488035 TO |
355 | public function valid() { |
356 | return isset($this->dataset[$this->i]); | |
357 | } | |
96025800 | 358 | |
6a488035 | 359 | } |