Merge pull request #15330 from mattwire/paymentprocessor_testmodelivemode
[civicrm-core.git] / tests / phpunit / CRM / Mailing / BAO / QueryTestDataProvider.php
CommitLineData
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 */
8class CRM_Mailing_BAO_QueryTestDataProvider implements Iterator {
9
10 /**
9f266042 11 * @var int
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 */
9099cab3
CW
21 private $dataset = [
22 [
23 'fv' => ['mailing_name' => 'First%', 'mailing_open_status' => 'Y'],
24 'id' => [109, 110, 111, 112],
25 ],
26 [
27 'fv' => ['mailing_name' => 'First%', 'mailing_open_status' => 'N'],
28 'id' => [102, 103, 104, 105, 108],
29 ],
6a488035 30 /*bounce*/
9099cab3
CW
31 [
32 'fv' => [
92915c55
TO
33 'mailing_name' => 'First%',
34 'mailing_delivery_status'
79d7553f 35 => 'N',
9099cab3
CW
36 ],
37 'id' => [105],
38 ],
6a488035 39 /*bounce*/
9099cab3
CW
40 [
41 'fv' => [
92915c55
TO
42 'mailing_name' => 'First%',
43 'mailing_delivery_status'
79d7553f 44 => 'Y',
9099cab3
CW
45 ],
46 'id' => [102, 103, 104, 108, 109, 110, 111, 112],
47 ],
48 [
49 'fv' => ['mailing_name' => 'First%', 'mailing_reply_status' => 'Y'],
50 'id' => [103, 108, 110, 112],
51 ],
52 [
53 'fv' => ['mailing_name' => 'First%', 'mailing_reply_status' => 'N'],
54 'id' => [102, 104, 105, 109, 111],
55 ],
56 [
57 'fv' => ['mailing_name' => 'First%', 'mailing_click_status' => 'Y'],
58 'id' => [104, 108, 111, 112],
59 ],
60 [
61 'fv' => ['mailing_name' => 'First%', 'mailing_click_status' => 'N'],
62 'id' => [102, 103, 105, 109, 110],
63 ],
6a488035 64 /*bounce*/
9099cab3
CW
65 [
66 'fv' => [
92915c55
TO
67 'mailing_name' => 'Second%',
68 'mailing_delivery_status'
79d7553f 69 => 'N',
9099cab3
CW
70 ],
71 'id' => [],
72 ],
6a488035 73 /*bounce*/
9099cab3
CW
74 [
75 'fv' => [
92915c55
TO
76 'mailing_name' => 'Second%',
77 'mailing_delivery_status'
79d7553f 78 => 'Y',
9099cab3
CW
79 ],
80 'id' => [102, 103, 104, 108, 109, 110, 111, 112],
81 ],
82 [
83 'fv' => ['mailing_name' => 'Second%', 'mailing_reply_status' => 'Y'],
84 'id' => [103],
85 ],
86 [
87 'fv' => ['mailing_name' => 'Second%', 'mailing_click_status' => 'Y'],
88 'id' => [104],
89 ],
90 [
91 'fv' => ['mailing_name' => 'Second%', 'mailing_click_status' => 'N'],
92 'id' => [102, 103, 108, 109, 110, 111, 112],
93 ],
94 [
95 'fv' => ['mailing_date_high' => '2011-05-25', 'mailing_open_status' => 'Y'],
96 'id' => [109, 110, 111, 112],
97 ],
98 [
99 'fv' => ['mailing_date_high' => '2011-05-25', 'mailing_open_status' => 'N'],
100 'id' => [102, 103, 104, 105, 108],
101 ],
102 [
103 'fv' => ['mailing_date_low' => '2011-05-26', 'mailing_open_status' => 'Y'],
104 'id' => [102],
105 ],
106 [
107 'fv' => ['mailing_date_low' => '2011-05-26', 'mailing_open_status' => 'N'],
108 'id' => [103, 104, 108, 109, 110, 111, 112],
109 ],
110 ];
6a488035
TO
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 125 $ids = $this->dataset[$this->i]['id'];
9099cab3 126 $full = [];
6a488035 127 foreach ($this->dataset[$this->i]['id'] as $key => $value) {
9099cab3 128 $full[] = [
6a488035
TO
129 'contact_id' => $value,
130 'contact_type' => 'Individual',
131 'sort_name' => "Test Contact $value",
9099cab3 132 ];
6a488035 133 }
9099cab3 134 return [$this->dataset[$this->i]['fv'], $count, $ids, $full];
6a488035
TO
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}