Autoformat /tests directory with php short array syntax
[civicrm-core.git] / tests / phpunit / CRM / Contact / BAO / QueryTestDataProvider.php
CommitLineData
6a488035
TO
1<?php
2// vim: set si ai expandtab tabstop=4 shiftwidth=4 softtabstop=4:
3
4/**
5 * File for the CRM_Contact_BAO_Query class
6 *
7 * (PHP 5)
8 *
6c6e6187
TO
9 * @author Walt Haas <walt@dharmatech.org> (801) 534-1262
10 * @copyright Copyright CiviCRM LLC (C) 2009
11 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html
6a488035 12 * GNU Affero General Public License version 3
6c6e6187
TO
13 * @version $Id: GroupTestDataProvider.php 23715 2009-09-21 06:35:47Z shot $
14 * @package CiviCRM
6a488035
TO
15 *
16 * This file is part of CiviCRM
17 *
18 * CiviCRM is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Affero General Public License
20 * as published by the Free Software Foundation; either version 3 of
21 * the License, or (at your option) any later version.
22 *
23 * CiviCRM is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Affero General Public License for more details.
27 *
28 * You should have received a copy of the GNU Affero General Public
29 * License along with this program. If not, see
30 * <http://www.gnu.org/licenses/>.
31 */
32
33/**
34 * Provide data to the CRM_Contact_BAO_QueryTest class
35 *
6c6e6187 36 * @package CiviCRM
6a488035
TO
37 */
38class CRM_Contact_BAO_QueryTestDataProvider implements Iterator {
39
40 /**
9f266042 41 * Current count.
42 *
43 * @var int
6a488035
TO
44 */
45 private $i = 0;
46
47 /**
6c6e6187 48 * @var mixed[]
6a488035
TO
49 * This dataset describes various form values and what contact
50 * IDs should be selected when the form values are applied to the
51 * database in dataset.xml
52 */
9099cab3 53 private $dataset = [
eba243b1 54 // Include static group 3
9099cab3
CW
55 [
56 'fv' => ['group' => '3'],
57 'id' => [
92915c55
TO
58 '17',
59 '18',
60 '19',
61 '20',
62 '21',
63 '22',
64 '23',
65 '24',
9099cab3
CW
66 ],
67 ],
eba243b1 68 // Include static group 5
9099cab3
CW
69 [
70 'fv' => ['group' => '5'],
71 'id' => [
92915c55
TO
72 '13',
73 '14',
74 '15',
75 '16',
76 '21',
77 '22',
78 '23',
79 '24',
9099cab3
CW
80 ],
81 ],
eba243b1 82 // Include static groups 3 and 5
9099cab3
CW
83 [
84 'fv' => ['group' => ['3', '5']],
85 'id' => [
92915c55
TO
86 '13',
87 '14',
88 '15',
89 '16',
90 '17',
91 '18',
92 '19',
93 '20',
94 '21',
95 '22',
96 '23',
97 '24',
9099cab3
CW
98 ],
99 ],
e34642c9 100 // Include static groups 3 and 5 in legacy format
9099cab3
CW
101 [
102 'fv' => ['group' => ['3' => 1, '5' => 1]],
103 'id' => [
e34642c9 104 '13',
105 '14',
106 '15',
107 '16',
108 '17',
109 '18',
110 '19',
111 '20',
112 '21',
113 '22',
114 '23',
115 '24',
9099cab3
CW
116 ],
117 ],
eba243b1 118 // Include tag 7
9099cab3
CW
119 [
120 'fv' => ['tag' => '7'],
121 'id' => [
92915c55
TO
122 '11',
123 '12',
124 '15',
125 '16',
126 '19',
127 '20',
128 '23',
129 '24',
9099cab3
CW
130 ],
131 ],
eba243b1 132 // Include tag 9
9099cab3
CW
133 [
134 'fv' => ['tag' => ['9' => 1]],
135 'id' => [
92915c55
TO
136 '10',
137 '12',
138 '14',
139 '16',
140 '18',
141 '20',
142 '22',
143 '24',
9099cab3
CW
144 ],
145 ],
eba243b1 146 // Include tags 7 and 9
9099cab3
CW
147 [
148 'fv' => ['tag' => ['7', '9']],
149 'id' => [
92915c55
TO
150 '10',
151 '11',
152 '12',
153 '14',
154 '15',
155 '16',
156 '18',
157 '19',
158 '20',
159 '22',
160 '23',
161 '24',
9099cab3
CW
162 ],
163 ],
f11f9737 164 // gender_id 1 = 'Female'
9099cab3
CW
165 [
166 'fv' => ['gender_id' => 1],
167 'id' => ['9', '20', '22'],
168 ],
f11f9737 169 // prefix_id 2 = 'Ms.'
9099cab3
CW
170 [
171 'fv' => ['prefix_id' => 2],
172 'id' => ['10', '13'],
173 ],
f11f9737 174 // suffix_id 6 = 'V'
9099cab3
CW
175 [
176 'fv' => ['suffix_id' => 6],
177 'id' => ['16', '19', '20', '21'],
178 ],
179 ];
6a488035
TO
180
181 public function _construct() {
182 $this->i = 0;
183 }
184
185 public function rewind() {
186 $this->i = 0;
187 }
188
4cbe18b8
EM
189 /**
190 * @return array
191 */
6a488035
TO
192 public function current() {
193 $count = count($this->dataset[$this->i]['id']);
92915c55 194 $ids = $this->dataset[$this->i]['id'];
9099cab3 195 $full = [];
6a488035 196 foreach ($this->dataset[$this->i]['id'] as $key => $value) {
9099cab3 197 $full[] = [
6a488035
TO
198 'contact_id' => $value,
199 'contact_type' => 'Individual',
200 'sort_name' => "Test Contact $value",
9099cab3 201 ];
6a488035 202 }
9099cab3 203 return [$this->dataset[$this->i]['fv'], $count, $ids, $full];
6a488035
TO
204 }
205
4cbe18b8
EM
206 /**
207 * @return int
208 */
6a488035
TO
209 public function key() {
210 return $this->i;
211 }
212
213 public function next() {
214 $this->i++;
215 }
216
4cbe18b8
EM
217 /**
218 * @return bool
219 */
6a488035
TO
220 public function valid() {
221 return isset($this->dataset[$this->i]);
222 }
96025800 223
6a488035
TO
224}
225// class CRM_Contact_BAO_QueryTestDataProvider