Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
92915c55 | 2 | |
6a488035 TO |
3 | /** |
4 | * Provide data to the CRM_Mailing_BAO_QueryTest class | |
5 | * | |
6c6e6187 | 6 | * @package CiviCRM |
6a488035 TO |
7 | */ |
8 | class CRM_Mailing_BAO_QueryTestDataProvider implements Iterator { | |
9 | ||
10 | /** | |
6c6e6187 | 11 | * @var integer |
6a488035 TO |
12 | */ |
13 | private $i = 0; | |
14 | ||
15 | /** | |
6c6e6187 | 16 | * @var mixed[] |
6a488035 TO |
17 | * This dataset describes various form values and what contact |
18 | * IDs should be selected when the form values are applied to the | |
19 | * database in dataset.xml | |
20 | */ | |
21 | private $dataset = array( | |
6c6e6187 | 22 | array( |
92915c55 | 23 | 'fv' => array('mailing_name' => 'First%', 'mailing_open_status' => 'Y'), |
6a488035 TO |
24 | 'id' => array(109, 110, 111, 112), |
25 | ), | |
6c6e6187 | 26 | array( |
92915c55 | 27 | 'fv' => array('mailing_name' => 'First%', 'mailing_open_status' => 'N'), |
6a488035 TO |
28 | 'id' => array(102, 103, 104, 105, 108), |
29 | ), | |
30 | /*bounce*/ | |
31 | array( | |
6c6e6187 | 32 | 'fv' => array( |
92915c55 TO |
33 | 'mailing_name' => 'First%', |
34 | 'mailing_delivery_status' | |
79d7553f | 35 | => 'N', |
92915c55 | 36 | ), |
6a488035 TO |
37 | 'id' => array(105), |
38 | ), | |
39 | /*bounce*/ | |
40 | array( | |
6c6e6187 | 41 | 'fv' => array( |
92915c55 TO |
42 | 'mailing_name' => 'First%', |
43 | 'mailing_delivery_status' | |
79d7553f | 44 | => 'Y', |
92915c55 | 45 | ), |
6a488035 TO |
46 | 'id' => array(102, 103, 104, 108, 109, 110, 111, 112), |
47 | ), | |
6c6e6187 | 48 | array( |
92915c55 | 49 | 'fv' => array('mailing_name' => 'First%', 'mailing_reply_status' => 'Y'), |
6a488035 TO |
50 | 'id' => array(103, 108, 110, 112), |
51 | ), | |
6c6e6187 | 52 | array( |
92915c55 | 53 | 'fv' => array('mailing_name' => 'First%', 'mailing_reply_status' => 'N'), |
6a488035 TO |
54 | 'id' => array(102, 104, 105, 109, 111), |
55 | ), | |
6c6e6187 | 56 | array( |
92915c55 | 57 | 'fv' => array('mailing_name' => 'First%', 'mailing_click_status' => 'Y'), |
6a488035 TO |
58 | 'id' => array(104, 108, 111, 112), |
59 | ), | |
6c6e6187 | 60 | array( |
92915c55 | 61 | 'fv' => array('mailing_name' => 'First%', 'mailing_click_status' => 'N'), |
6a488035 TO |
62 | 'id' => array(102, 103, 105, 109, 110), |
63 | ), | |
64 | /*bounce*/ | |
65 | array( | |
6c6e6187 | 66 | 'fv' => array( |
92915c55 TO |
67 | 'mailing_name' => 'Second%', |
68 | 'mailing_delivery_status' | |
79d7553f | 69 | => 'N', |
92915c55 | 70 | ), |
6a488035 TO |
71 | 'id' => array(), |
72 | ), | |
73 | /*bounce*/ | |
74 | array( | |
6c6e6187 | 75 | 'fv' => array( |
92915c55 TO |
76 | 'mailing_name' => 'Second%', |
77 | 'mailing_delivery_status' | |
79d7553f | 78 | => 'Y', |
92915c55 | 79 | ), |
6a488035 TO |
80 | 'id' => array(102, 103, 104, 108, 109, 110, 111, 112), |
81 | ), | |
6c6e6187 | 82 | array( |
92915c55 | 83 | 'fv' => array('mailing_name' => 'Second%', 'mailing_reply_status' => 'Y'), |
6a488035 TO |
84 | 'id' => array(103), |
85 | ), | |
6c6e6187 | 86 | array( |
92915c55 | 87 | 'fv' => array('mailing_name' => 'Second%', 'mailing_click_status' => 'Y'), |
6a488035 TO |
88 | 'id' => array(104), |
89 | ), | |
6c6e6187 | 90 | array( |
92915c55 | 91 | 'fv' => array('mailing_name' => 'Second%', 'mailing_click_status' => 'N'), |
6a488035 TO |
92 | 'id' => array(102, 103, 108, 109, 110, 111, 112), |
93 | ), | |
6c6e6187 | 94 | array( |
92915c55 | 95 | 'fv' => array('mailing_date_high' => '2011-05-25', 'mailing_open_status' => 'Y'), |
6a488035 TO |
96 | 'id' => array(109, 110, 111, 112), |
97 | ), | |
6c6e6187 | 98 | array( |
92915c55 | 99 | 'fv' => array('mailing_date_high' => '2011-05-25', 'mailing_open_status' => 'N'), |
6a488035 TO |
100 | 'id' => array(102, 103, 104, 105, 108), |
101 | ), | |
6c6e6187 | 102 | array( |
92915c55 | 103 | 'fv' => array('mailing_date_low' => '2011-05-26', 'mailing_open_status' => 'Y'), |
6a488035 TO |
104 | 'id' => array(102), |
105 | ), | |
6c6e6187 | 106 | array( |
92915c55 | 107 | 'fv' => array('mailing_date_low' => '2011-05-26', 'mailing_open_status' => 'N'), |
6a488035 TO |
108 | 'id' => array(103, 104, 108, 109, 110, 111, 112), |
109 | ), | |
110 | ); | |
111 | ||
112 | public function _construct() { | |
113 | $this->i = 0; | |
114 | } | |
115 | ||
116 | public function rewind() { | |
117 | $this->i = 0; | |
118 | } | |
119 | ||
4cbe18b8 EM |
120 | /** |
121 | * @return array | |
122 | */ | |
6a488035 TO |
123 | public function current() { |
124 | $count = count($this->dataset[$this->i]['id']); | |
92915c55 TO |
125 | $ids = $this->dataset[$this->i]['id']; |
126 | $full = array(); | |
6a488035 TO |
127 | foreach ($this->dataset[$this->i]['id'] as $key => $value) { |
128 | $full[] = array( | |
129 | 'contact_id' => $value, | |
130 | 'contact_type' => 'Individual', | |
131 | 'sort_name' => "Test Contact $value", | |
132 | ); | |
133 | } | |
134 | return array($this->dataset[$this->i]['fv'], $count, $ids, $full); | |
135 | } | |
136 | ||
4cbe18b8 EM |
137 | /** |
138 | * @return int | |
139 | */ | |
6a488035 TO |
140 | public function key() { |
141 | return $this->i; | |
142 | } | |
143 | ||
144 | public function next() { | |
145 | $this->i++; | |
146 | } | |
147 | ||
4cbe18b8 EM |
148 | /** |
149 | * @return bool | |
150 | */ | |
6a488035 TO |
151 | public function valid() { |
152 | return isset($this->dataset[$this->i]); | |
153 | } | |
96025800 | 154 | |
6a488035 | 155 | } |