2 // vim: set si ai expandtab tabstop=4 shiftwidth=4 softtabstop=4:
5 * File for the CRM_Contact_BAO_Query class
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 $
16 * This file is part of CiviCRM
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.
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.
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/>.
34 * Provide data to the CRM_Contact_BAO_QueryTest class
38 class CRM_Contact_BAO_QueryTestDataProvider
implements Iterator
{
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
51 private $dataset = array(
52 // Include static group 3
54 'fv' => array('group' => '3'),
66 // Include static group 5
68 'fv' => array('group' => '5'),
80 // Include static groups 3 and 5
82 'fv' => array('group' => array('3', '5')),
98 // Include static groups 3 and 5 in legacy format
100 'fv' => array('group' => array('3' => 1, '5' => 1)),
118 'fv' => array('tag' => '7'),
132 'fv' => array('tag' => array('9' => 1)),
144 // Include tags 7 and 9
146 'fv' => array('tag' => array('7', '9')),
162 // gender_id 1 = 'Female'
164 'fv' => array('gender_id' => 1),
165 'id' => array('9', '20', '22'),
167 // prefix_id 2 = 'Ms.'
169 'fv' => array('prefix_id' => 2),
170 'id' => array('10', '13'),
174 'fv' => array('suffix_id' => 6),
175 'id' => array('16', '19', '20', '21'),
179 public function _construct() {
183 public function rewind() {
190 public function current() {
191 $count = count($this->dataset
[$this->i
]['id']);
192 $ids = $this->dataset
[$this->i
]['id'];
194 foreach ($this->dataset
[$this->i
]['id'] as $key => $value) {
196 'contact_id' => $value,
197 'contact_type' => 'Individual',
198 'sort_name' => "Test Contact $value",
201 return array($this->dataset
[$this->i
]['fv'], $count, $ids, $full);
207 public function key() {
211 public function next() {
218 public function valid() {
219 return isset($this->dataset
[$this->i
]);
223 // class CRM_Contact_BAO_QueryTestDataProvider