Merge pull request #14279 from eileenmcnaughton/db_test2
[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 * @var integer
41 */
42 private $i = 0;
43
44 /**
45 * @var mixed[]
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
52 array(
53 'fv' => array('excludeGroups' => array('3')),
54 'id' => array(
55 '9',
56 '10',
57 '11',
58 '12',
59 '13',
60 '14',
61 '15',
62 '16',
63 '26',
64 ),
65 ),
66 // Include static group 3
67 array(
68 'fv' => array('includeGroups' => array('3')),
69 'id' => array(
70 '17',
71 '18',
72 '19',
73 '20',
74 '21',
75 '22',
76 '23',
77 '24',
78 '27',
79 '28',
80 ),
81 ),
82 // Include static group 5
83 array(
84 'fv' => array('includeGroups' => array('5')),
85 'id' => array(
86 '13',
87 '14',
88 '15',
89 '16',
90 '21',
91 '22',
92 '23',
93 '24',
94 ),
95 ),
96 // Include static groups 3 and 5
97 array(
98 'fv' => array('includeGroups' => array('3', '5')),
99 'id' => array(
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',
114 ),
115 ),
116 // Include static group 3, exclude static group 5
117 array(
118 'fv' => array(
119 'includeGroups' => array('3'),
120 'excludeGroups' => array('5'),
121 ),
122 'id' => array('17', '18', '19', '20', '27', '28'),
123 ),
124 // Exclude tag 7
125 array(
126 'fv' => array('excludeTags' => array('7')),
127 'id' => array(
128 '9',
129 '10',
130 '13',
131 '14',
132 '17',
133 '18',
134 '21',
135 '22',
136 '27',
137 ),
138 ),
139 // Include tag 7
140 array(
141 'fv' => array('includeTags' => array('7')),
142 'id' => array(
143 '11',
144 '12',
145 '15',
146 '16',
147 '19',
148 '20',
149 '23',
150 '24',
151 '26',
152 '28',
153 ),
154 ),
155 // Include tag 9
156 array(
157 'fv' => array('includeTags' => array('9')),
158 'id' => array(
159 '10',
160 '12',
161 '14',
162 '16',
163 '18',
164 '20',
165 '22',
166 '24',
167 ),
168 ),
169 // Include tags 7 and 9
170 array(
171 'fv' => array('includeTags' => array('7', '9')),
172 'id' => array(
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',
187 ),
188 ),
189 // Include tag 7, exclude tag 9
190 array(
191 'fv' => array(
192 'includeTags' => array('7'),
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(
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',
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
232 array(
233 'fv' => array(
234 'includeGroups' => array('3'),
235 'excludeTags' => array('7'),
236 ),
237 'id' => array('17', '18', '21', '22', '27'),
238 ),
239 // Include tag 9, exclude static group 5
240 array(
241 'fv' => array(
242 'includeTags' => array('9'),
243 'excludeGroups' => array('5'),
244 ),
245 'id' => array('10', '12', '18', '20'),
246 ),
247 // Exclude tag 9, exclude static group 5
248 array(
249 'fv' => array(
250 'excludeTags' => array('9'),
251 'excludeGroups' => array('5'),
252 ),
253 'id' => array(
254 '9',
255 '11',
256 '17',
257 '19',
258 '26',
259 '27',
260 '28',
261 ),
262 ),
263 // Include smart group 6
264 array(
265 'fv' => array('includeGroups' => array('6')),
266 'id' => array(
267 '9',
268 '10',
269 '11',
270 '12',
271 '13',
272 '14',
273 '15',
274 '16',
275 '26',
276 ),
277 ),
278 // Include smart group 4
279 array(
280 'fv' => array('includeGroups' => array('4')),
281 'id' => array(
282 '17',
283 '18',
284 '19',
285 '20',
286 '21',
287 '22',
288 '23',
289 '24',
290 '27',
291 '28',
292 ),
293 ),
294 // Include smart group 4 and static group 5
295 array(
296 'fv' => array('includeGroups' => array('4', '5')),
297 'id' => array(
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',
312 ),
313 ),
314 );
315
316 public function _construct() {
317 $this->i = 0;
318 }
319
320 public function rewind() {
321 $this->i = 0;
322 }
323
324 /**
325 * @return array
326 */
327 public function current() {
328 $count = count($this->dataset[$this->i]['id']);
329 $ids = $this->dataset[$this->i]['id'];
330 $full = array();
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
341 /**
342 * @return int
343 */
344 public function key() {
345 return $this->i;
346 }
347
348 public function next() {
349 $this->i++;
350 }
351
352 /**
353 * @return bool
354 */
355 public function valid() {
356 return isset($this->dataset[$this->i]);
357 }
358
359 }