Merge pull request #14734 from yashodha/dev-1104
[civicrm-core.git] / tests / phpunit / CRM / Contact / Form / Search / Custom / GroupTestDataProvider.php
1 <?php
2
3 /**
4 * File for the CRM_Contact_Form_Search_Custom_GroupTestDataProvider class
5 *
6 * (PHP 5)
7 *
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
11 * GNU Affero General Public License version 3
12 * @version $Id: GroupTestDataProvider.php 44314 2012-12-19 11:12:49Z kurund $
13 * @package CiviCRM
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 *
35 * @package CiviCRM
36 */
37 class CRM_Contact_Form_Search_Custom_GroupTestDataProvider implements Iterator {
38
39 /**
40 * Current count.
41 *
42 * @var int
43 */
44 private $i = 0;
45
46 /**
47 * @var mixed[]
48 * This dataset describes various form values and what contact
49 * IDs should be selected when the form values are applied to the
50 * database in dataset.xml
51 */
52 private $dataset = [
53 // Exclude static group 3
54 [
55 'fv' => ['excludeGroups' => ['3']],
56 'id' => [
57 '9',
58 '10',
59 '11',
60 '12',
61 '13',
62 '14',
63 '15',
64 '16',
65 '26',
66 ],
67 ],
68 // Include static group 3
69 [
70 'fv' => ['includeGroups' => ['3']],
71 'id' => [
72 '17',
73 '18',
74 '19',
75 '20',
76 '21',
77 '22',
78 '23',
79 '24',
80 '27',
81 '28',
82 ],
83 ],
84 // Include static group 5
85 [
86 'fv' => ['includeGroups' => ['5']],
87 'id' => [
88 '13',
89 '14',
90 '15',
91 '16',
92 '21',
93 '22',
94 '23',
95 '24',
96 ],
97 ],
98 // Include static groups 3 and 5
99 [
100 'fv' => ['includeGroups' => ['3', '5']],
101 'id' => [
102 '13',
103 '14',
104 '15',
105 '16',
106 '17',
107 '18',
108 '19',
109 '20',
110 '21',
111 '22',
112 '23',
113 '24',
114 '27',
115 '28',
116 ],
117 ],
118 // Include static group 3, exclude static group 5
119 [
120 'fv' => [
121 'includeGroups' => ['3'],
122 'excludeGroups' => ['5'],
123 ],
124 'id' => ['17', '18', '19', '20', '27', '28'],
125 ],
126 // Exclude tag 7
127 [
128 'fv' => ['excludeTags' => ['7']],
129 'id' => [
130 '9',
131 '10',
132 '13',
133 '14',
134 '17',
135 '18',
136 '21',
137 '22',
138 '27',
139 ],
140 ],
141 // Include tag 7
142 [
143 'fv' => ['includeTags' => ['7']],
144 'id' => [
145 '11',
146 '12',
147 '15',
148 '16',
149 '19',
150 '20',
151 '23',
152 '24',
153 '26',
154 '28',
155 ],
156 ],
157 // Include tag 9
158 [
159 'fv' => ['includeTags' => ['9']],
160 'id' => [
161 '10',
162 '12',
163 '14',
164 '16',
165 '18',
166 '20',
167 '22',
168 '24',
169 ],
170 ],
171 // Include tags 7 and 9
172 [
173 'fv' => ['includeTags' => ['7', '9']],
174 'id' => [
175 '10',
176 '11',
177 '12',
178 '14',
179 '15',
180 '16',
181 '18',
182 '19',
183 '20',
184 '22',
185 '23',
186 '24',
187 '26',
188 '28',
189 ],
190 ],
191 // Include tag 7, exclude tag 9
192 [
193 'fv' => [
194 'includeTags' => ['7'],
195 'excludeTags' => ['9'],
196 ],
197 'id' => ['11', '15', '19', '23', '26', '28'],
198 ],
199 // Include static group 3, include tag 7 (either)
200 [
201 'fv' => [
202 'includeGroups' => ['3'],
203 'includeTags' => ['7'],
204 'andOr' => 0,
205 ],
206 'id' => [
207 '11',
208 '12',
209 '15',
210 '16',
211 '17',
212 '18',
213 '19',
214 '20',
215 '21',
216 '22',
217 '23',
218 '24',
219 '26',
220 '27',
221 '28',
222 ],
223 ],
224 // Include static group 3, include tag 7 (both)
225 [
226 'fv' => [
227 'includeGroups' => ['3'],
228 'includeTags' => ['7'],
229 'andOr' => 1,
230 ],
231 'id' => ['19', '20', '23', '24', '28'],
232 ],
233 // Include static group 3, exclude tag 7
234 [
235 'fv' => [
236 'includeGroups' => ['3'],
237 'excludeTags' => ['7'],
238 ],
239 'id' => ['17', '18', '21', '22', '27'],
240 ],
241 // Include tag 9, exclude static group 5
242 [
243 'fv' => [
244 'includeTags' => ['9'],
245 'excludeGroups' => ['5'],
246 ],
247 'id' => ['10', '12', '18', '20'],
248 ],
249 // Exclude tag 9, exclude static group 5
250 [
251 'fv' => [
252 'excludeTags' => ['9'],
253 'excludeGroups' => ['5'],
254 ],
255 'id' => [
256 '9',
257 '11',
258 '17',
259 '19',
260 '26',
261 '27',
262 '28',
263 ],
264 ],
265 // Include smart group 6
266 [
267 'fv' => ['includeGroups' => ['6']],
268 'id' => [
269 '9',
270 '10',
271 '11',
272 '12',
273 '13',
274 '14',
275 '15',
276 '16',
277 '26',
278 ],
279 ],
280 // Include smart group 4
281 [
282 'fv' => ['includeGroups' => ['4']],
283 'id' => [
284 '17',
285 '18',
286 '19',
287 '20',
288 '21',
289 '22',
290 '23',
291 '24',
292 '27',
293 '28',
294 ],
295 ],
296 // Include smart group 4 and static group 5
297 [
298 'fv' => ['includeGroups' => ['4', '5']],
299 'id' => [
300 '13',
301 '14',
302 '15',
303 '16',
304 '17',
305 '18',
306 '19',
307 '20',
308 '21',
309 '22',
310 '23',
311 '24',
312 '27',
313 '28',
314 ],
315 ],
316 ];
317
318 public function _construct() {
319 $this->i = 0;
320 }
321
322 public function rewind() {
323 $this->i = 0;
324 }
325
326 /**
327 * @return array
328 */
329 public function current() {
330 $count = count($this->dataset[$this->i]['id']);
331 $ids = $this->dataset[$this->i]['id'];
332 $full = [];
333 foreach ($this->dataset[$this->i]['id'] as $key => $value) {
334 $full[] = [
335 'contact_id' => $value,
336 'contact_type' => 'Individual',
337 'sort_name' => "Test Contact $value",
338 ];
339 }
340 return [$this->dataset[$this->i]['fv'], $count, $ids, $full];
341 }
342
343 /**
344 * @return int
345 */
346 public function key() {
347 return $this->i;
348 }
349
350 public function next() {
351 $this->i++;
352 }
353
354 /**
355 * @return bool
356 */
357 public function valid() {
358 return isset($this->dataset[$this->i]);
359 }
360
361 }