add missing comments - tests directory
[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' => array('3' => 1)),
55 'id' => array(
56 '17', '18', '19', '20', '21',
57 '22', '23', '24',
58 ),
59 ),
60 // Include static group 5
61 array(
62 'fv' => array('group' => array('5' => 1)),
63 'id' => array(
64 '13', '14', '15', '16', '21',
65 '22', '23', '24',
66 ),
67 ),
68 // Include static groups 3 and 5
69 array(
70 'fv' => array('group' => array('3' => 1, '5' => 1)),
71 'id' => array(
72 '13', '14', '15', '16', '17', '18',
73 '19', '20', '21', '22', '23', '24',
74 ),
75 ),
76 // Include tag 7
77 array(
78 'fv' => array('tag' => array('7' => 1)),
79 'id' => array(
80 '11', '12', '15', '16',
81 '19', '20', '23', '24',
82 ),
83 ),
84 // Include tag 9
85 array(
86 'fv' => array('tag' => array('9' => 1)),
87 'id' => array(
88 '10', '12', '14', '16',
89 '18', '20', '22', '24',
90 ),
91 ),
92 // Include tags 7 and 9
93 array(
94 'fv' => array('tag' => array('7' => 1, '9' => 1)),
95 'id' => array(
96 '10', '11', '12', '14', '15', '16',
97 '18', '19', '20', '22', '23', '24',
98 ),
99 ),
100
101 // gender_id 1 = 'Female'
102 array(
103 'fv' => array('gender_id' => 1),
104 'id' => array('9', '20', '22'),
105 ),
106 // prefix_id 2 = 'Ms.'
107 array(
108 'fv' => array('prefix_id' => 2),
109 'id' => array('10', '13'),
110 ),
111 // suffix_id 6 = 'V'
112 array(
113 'fv' => array('suffix_id' => 6),
114 'id' => array('16', '19', '20', '21'),
115 ),
116 );
117
118 public function _construct() {
119 $this->i = 0;
120 }
121
122 public function rewind() {
123 $this->i = 0;
124 }
125
126 /**
127 * @return array
128 */
129 public function current() {
130 $count = count($this->dataset[$this->i]['id']);
131 $ids = $this->dataset[$this->i]['id'];
132 $full = array();
133 foreach ($this->dataset[$this->i]['id'] as $key => $value) {
134 $full[] = array(
135 'contact_id' => $value,
136 'contact_type' => 'Individual',
137 'sort_name' => "Test Contact $value",
138 );
139 }
140 return array($this->dataset[$this->i]['fv'], $count, $ids, $full);
141 }
142
143 /**
144 * @return int
145 */
146 public function key() {
147 return $this->i;
148 }
149
150 public function next() {
151 $this->i++;
152 }
153
154 /**
155 * @return bool
156 */
157 public function valid() {
158 return isset($this->dataset[$this->i]);
159 }
160 }
161 // class CRM_Contact_BAO_QueryTestDataProvider