CRM_Contact_BAO_QueryTest - Update assertion on ORDER BY to use backtick
[civicrm-core.git] / tests / phpunit / CRM / Contact / BAO / QueryTestDataProvider.php
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 *
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
12 * GNU Affero General Public License version 3
13 * @version $Id: GroupTestDataProvider.php 23715 2009-09-21 06:35:47Z shot $
14 * @package CiviCRM
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 *
36 * @package CiviCRM
37 */
38 class CRM_Contact_BAO_QueryTestDataProvider implements Iterator {
39
40 /**
41 * @var integer
42 */
43 private $i = 0;
44
45 /**
46 * @var mixed[]
47 * This dataset describes various form values and what contact
48 * IDs should be selected when the form values are applied to the
49 * database in dataset.xml
50 */
51 private $dataset = array(
52 // Include static group 3
53 array(
54 'fv' => array('group' => '3'),
55 'id' => array(
56 '17',
57 '18',
58 '19',
59 '20',
60 '21',
61 '22',
62 '23',
63 '24',
64 ),
65 ),
66 // Include static group 5
67 array(
68 'fv' => array('group' => '5'),
69 'id' => array(
70 '13',
71 '14',
72 '15',
73 '16',
74 '21',
75 '22',
76 '23',
77 '24',
78 ),
79 ),
80 // Include static groups 3 and 5
81 array(
82 'fv' => array('group' => array('3', '5')),
83 'id' => array(
84 '13',
85 '14',
86 '15',
87 '16',
88 '17',
89 '18',
90 '19',
91 '20',
92 '21',
93 '22',
94 '23',
95 '24',
96 ),
97 ),
98 // Include static groups 3 and 5 in legacy format
99 array(
100 'fv' => array('group' => array('3' => 1, '5' => 1)),
101 'id' => array(
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 ),
115 ),
116 // Include tag 7
117 array(
118 'fv' => array('tag' => '7'),
119 'id' => array(
120 '11',
121 '12',
122 '15',
123 '16',
124 '19',
125 '20',
126 '23',
127 '24',
128 ),
129 ),
130 // Include tag 9
131 array(
132 'fv' => array('tag' => array('9' => 1)),
133 'id' => array(
134 '10',
135 '12',
136 '14',
137 '16',
138 '18',
139 '20',
140 '22',
141 '24',
142 ),
143 ),
144 // Include tags 7 and 9
145 array(
146 'fv' => array('tag' => array('7', '9')),
147 'id' => array(
148 '10',
149 '11',
150 '12',
151 '14',
152 '15',
153 '16',
154 '18',
155 '19',
156 '20',
157 '22',
158 '23',
159 '24',
160 ),
161 ),
162 // gender_id 1 = 'Female'
163 array(
164 'fv' => array('gender_id' => 1),
165 'id' => array('9', '20', '22'),
166 ),
167 // prefix_id 2 = 'Ms.'
168 array(
169 'fv' => array('prefix_id' => 2),
170 'id' => array('10', '13'),
171 ),
172 // suffix_id 6 = 'V'
173 array(
174 'fv' => array('suffix_id' => 6),
175 'id' => array('16', '19', '20', '21'),
176 ),
177 );
178
179 public function _construct() {
180 $this->i = 0;
181 }
182
183 public function rewind() {
184 $this->i = 0;
185 }
186
187 /**
188 * @return array
189 */
190 public function current() {
191 $count = count($this->dataset[$this->i]['id']);
192 $ids = $this->dataset[$this->i]['id'];
193 $full = array();
194 foreach ($this->dataset[$this->i]['id'] as $key => $value) {
195 $full[] = array(
196 'contact_id' => $value,
197 'contact_type' => 'Individual',
198 'sort_name' => "Test Contact $value",
199 );
200 }
201 return array($this->dataset[$this->i]['fv'], $count, $ids, $full);
202 }
203
204 /**
205 * @return int
206 */
207 public function key() {
208 return $this->i;
209 }
210
211 public function next() {
212 $this->i++;
213 }
214
215 /**
216 * @return bool
217 */
218 public function valid() {
219 return isset($this->dataset[$this->i]);
220 }
221
222 }
223 // class CRM_Contact_BAO_QueryTestDataProvider