Merge pull request #14868 from civicrm/5.16
[civicrm-core.git] / tests / phpunit / CRM / Contact / Form / Search / Custom / GroupTestDataProvider.php
CommitLineData
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 */
37class CRM_Contact_Form_Search_Custom_GroupTestDataProvider implements Iterator {
38
39 /**
9f266042 40 * Current count.
41 *
42 * @var int
6a488035
TO
43 */
44 private $i = 0;
45
46 /**
6c6e6187 47 * @var mixed[]
6a488035
TO
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 */
9099cab3 52 private $dataset = [
6a488035 53 // Exclude static group 3
9099cab3
CW
54 [
55 'fv' => ['excludeGroups' => ['3']],
56 'id' => [
92915c55
TO
57 '9',
58 '10',
59 '11',
60 '12',
61 '13',
62 '14',
63 '15',
64 '16',
65 '26',
9099cab3
CW
66 ],
67 ],
6a488035 68 // Include static group 3
9099cab3
CW
69 [
70 'fv' => ['includeGroups' => ['3']],
71 'id' => [
92915c55
TO
72 '17',
73 '18',
74 '19',
75 '20',
76 '21',
77 '22',
78 '23',
79 '24',
80 '27',
81 '28',
9099cab3
CW
82 ],
83 ],
6a488035 84 // Include static group 5
9099cab3
CW
85 [
86 'fv' => ['includeGroups' => ['5']],
87 'id' => [
92915c55
TO
88 '13',
89 '14',
90 '15',
91 '16',
92 '21',
93 '22',
94 '23',
95 '24',
9099cab3
CW
96 ],
97 ],
6a488035 98 // Include static groups 3 and 5
9099cab3
CW
99 [
100 'fv' => ['includeGroups' => ['3', '5']],
101 'id' => [
92915c55
TO
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',
9099cab3
CW
116 ],
117 ],
6a488035 118 // Include static group 3, exclude static group 5
9099cab3
CW
119 [
120 'fv' => [
121 'includeGroups' => ['3'],
122 'excludeGroups' => ['5'],
123 ],
124 'id' => ['17', '18', '19', '20', '27', '28'],
125 ],
6a488035 126 // Exclude tag 7
9099cab3
CW
127 [
128 'fv' => ['excludeTags' => ['7']],
129 'id' => [
92915c55
TO
130 '9',
131 '10',
132 '13',
133 '14',
134 '17',
135 '18',
136 '21',
137 '22',
138 '27',
9099cab3
CW
139 ],
140 ],
6a488035 141 // Include tag 7
9099cab3
CW
142 [
143 'fv' => ['includeTags' => ['7']],
144 'id' => [
92915c55
TO
145 '11',
146 '12',
147 '15',
148 '16',
149 '19',
150 '20',
151 '23',
152 '24',
153 '26',
154 '28',
9099cab3
CW
155 ],
156 ],
6a488035 157 // Include tag 9
9099cab3
CW
158 [
159 'fv' => ['includeTags' => ['9']],
160 'id' => [
92915c55
TO
161 '10',
162 '12',
163 '14',
164 '16',
165 '18',
166 '20',
167 '22',
168 '24',
9099cab3
CW
169 ],
170 ],
6a488035 171 // Include tags 7 and 9
9099cab3
CW
172 [
173 'fv' => ['includeTags' => ['7', '9']],
174 'id' => [
92915c55
TO
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',
9099cab3
CW
189 ],
190 ],
6a488035 191 // Include tag 7, exclude tag 9
9099cab3
CW
192 [
193 'fv' => [
194 'includeTags' => ['7'],
195 'excludeTags' => ['9'],
196 ],
197 'id' => ['11', '15', '19', '23', '26', '28'],
198 ],
6a488035 199 // Include static group 3, include tag 7 (either)
9099cab3
CW
200 [
201 'fv' => [
202 'includeGroups' => ['3'],
203 'includeTags' => ['7'],
6a488035 204 'andOr' => 0,
9099cab3
CW
205 ],
206 'id' => [
92915c55
TO
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',
9099cab3
CW
222 ],
223 ],
6a488035 224 // Include static group 3, include tag 7 (both)
9099cab3
CW
225 [
226 'fv' => [
227 'includeGroups' => ['3'],
228 'includeTags' => ['7'],
6a488035 229 'andOr' => 1,
9099cab3
CW
230 ],
231 'id' => ['19', '20', '23', '24', '28'],
232 ],
6a488035 233 // Include static group 3, exclude tag 7
9099cab3
CW
234 [
235 'fv' => [
236 'includeGroups' => ['3'],
237 'excludeTags' => ['7'],
238 ],
239 'id' => ['17', '18', '21', '22', '27'],
240 ],
6a488035 241 // Include tag 9, exclude static group 5
9099cab3
CW
242 [
243 'fv' => [
244 'includeTags' => ['9'],
245 'excludeGroups' => ['5'],
246 ],
247 'id' => ['10', '12', '18', '20'],
248 ],
6a488035 249 // Exclude tag 9, exclude static group 5
9099cab3
CW
250 [
251 'fv' => [
252 'excludeTags' => ['9'],
253 'excludeGroups' => ['5'],
254 ],
255 'id' => [
92915c55
TO
256 '9',
257 '11',
258 '17',
259 '19',
260 '26',
261 '27',
262 '28',
9099cab3
CW
263 ],
264 ],
6a488035 265 // Include smart group 6
9099cab3
CW
266 [
267 'fv' => ['includeGroups' => ['6']],
268 'id' => [
92915c55
TO
269 '9',
270 '10',
271 '11',
272 '12',
273 '13',
274 '14',
275 '15',
276 '16',
277 '26',
9099cab3
CW
278 ],
279 ],
6a488035 280 // Include smart group 4
9099cab3
CW
281 [
282 'fv' => ['includeGroups' => ['4']],
283 'id' => [
92915c55
TO
284 '17',
285 '18',
286 '19',
287 '20',
288 '21',
289 '22',
290 '23',
291 '24',
292 '27',
293 '28',
9099cab3
CW
294 ],
295 ],
6a488035 296 // Include smart group 4 and static group 5
9099cab3
CW
297 [
298 'fv' => ['includeGroups' => ['4', '5']],
299 'id' => [
92915c55
TO
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',
9099cab3
CW
314 ],
315 ],
316 ];
6a488035
TO
317
318 public function _construct() {
319 $this->i = 0;
320 }
321
322 public function rewind() {
323 $this->i = 0;
324 }
325
4cbe18b8
EM
326 /**
327 * @return array
328 */
6a488035
TO
329 public function current() {
330 $count = count($this->dataset[$this->i]['id']);
92915c55 331 $ids = $this->dataset[$this->i]['id'];
9099cab3 332 $full = [];
6a488035 333 foreach ($this->dataset[$this->i]['id'] as $key => $value) {
9099cab3 334 $full[] = [
6a488035
TO
335 'contact_id' => $value,
336 'contact_type' => 'Individual',
337 'sort_name' => "Test Contact $value",
9099cab3 338 ];
6a488035 339 }
9099cab3 340 return [$this->dataset[$this->i]['fv'], $count, $ids, $full];
6a488035
TO
341 }
342
4cbe18b8
EM
343 /**
344 * @return int
345 */
6a488035
TO
346 public function key() {
347 return $this->i;
348 }
349
350 public function next() {
351 $this->i++;
352 }
353
4cbe18b8
EM
354 /**
355 * @return bool
356 */
6a488035
TO
357 public function valid() {
358 return isset($this->dataset[$this->i]);
359 }
96025800 360
6a488035 361}