tests/phpunit/** - Remove unnecessary "require_once" statements
[civicrm-core.git] / tests / phpunit / CRM / Contribute / ActionMapping / ByTypeTest.php
CommitLineData
14d24938
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
3435af9a 4 | CiviCRM version 4.7 |
14d24938
TO
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
0eea664b
TO
28/**
29 */
14d24938
TO
30class CRM_Contribute_ActionMapping_ByTypeTest extends \Civi\ActionSchedule\AbstractMappingTest {
31
32 /**
33 * Generate a list of test cases, where each is a distinct combination of
34 * data, schedule-rules, and schedule results.
35 *
36 * @return array
37 * - targetDate: string; eg "2015-02-01 00:00:01"
38 * - setupFuncs: string, space-separated list of setup functions
39 * - messages: array; each item is a message that's expected to be sent
40 * each message may include keys:
41 * - time: approximate time (give or take a few seconds)
42 * - recipients: array of emails
43 * - subject: regex
44 */
45 public function createTestCases() {
46 $cs = array();
47
48 $cs[] = array(
49 '2015-02-01 00:00:00',
50 'addAliceDues addBobDonation scheduleForDues startOnTime useHelloFirstName',
51 array(
52 array(
53 'time' => '2015-02-01 00:00:00',
54 'to' => array('alice@example.org'),
55 'subject' => '/Hello, Alice.*via subject/',
56 ),
57 ),
58 );
59
60 $cs[] = array(
61 '2015-02-01 00:00:00',
62 'addAliceDues addBobDonation scheduleForAny startOnTime useHelloFirstName',
63 array(
64 array(
65 'time' => '2015-02-01 00:00:00',
66 'to' => array('alice@example.org'),
67 'subject' => '/Hello, Alice.*via subject/',
68 ),
69 array(
70 'time' => '2015-02-01 00:00:00',
71 'to' => array('bob@example.org'),
72 'subject' => '/Hello, Bob.*via subject/',
73 ),
74 ),
75 );
76
77 $cs[] = array(
78 '2015-02-02 00:00:00',
79 'addAliceDues addBobDonation scheduleForDonation startWeekBefore repeatTwoWeeksAfter useHelloFirstName',
80 array(
81 array(
82 'time' => '2015-01-26 00:00:00',
83 'to' => array('bob@example.org'),
84 'subject' => '/Hello, Bob.*via subject/',
85 ),
86 array(
87 'time' => '2015-02-02 00:00:00',
88 'to' => array('bob@example.org'),
89 'subject' => '/Hello, Bob.*via subject/',
90 ),
91 array(
92 'time' => '2015-02-09 00:00:00',
93 'to' => array('bob@example.org'),
94 'subject' => '/Hello, Bob.*via subject/',
95 ),
96 array(
97 'time' => '2015-02-16 00:00:00',
98 'to' => array('bob@example.org'),
99 'subject' => '/Hello, Bob.*via subject/',
100 ),
101 ),
102 );
103
104 $cs[] = array(
105 '2015-02-03 00:00:00',
106 'addAliceDues addBobDonation scheduleForSoftCreditor startWeekAfter useHelloFirstName',
107 array(
108 array(
109 'time' => '2015-02-10 00:00:00',
110 'to' => array('carol@example.org'),
111 'subject' => '/Hello, Carol.*via subject/',
112 ),
113 ),
114 );
115
116 return $cs;
117 }
118
119 public function addAliceDues() {
120 $this->callAPISuccess('Contribution', 'create', array(
121 'contact_id' => $this->contacts['alice']['id'],
122 'receive_date' => date('Ymd', strtotime($this->targetDate)),
123 'total_amount' => '100',
124 'financial_type_id' => 1,
125 'non_deductible_amount' => '10',
126 'fee_amount' => '5',
127 'net_amount' => '95',
128 'source' => 'SSF',
129 'contribution_status_id' => 1,
130 'soft_credit' => array(
131 '1' => array(
132 'contact_id' => $this->contacts['carol']['id'],
133 'amount' => 50,
134 'soft_credit_type_id' => 3,
135 ),
136 ),
137 ));
138 }
139
140 public function addBobDonation() {
141 $this->callAPISuccess('Contribution', 'create', array(
142 'contact_id' => $this->contacts['bob']['id'],
143 'receive_date' => date('Ymd', strtotime($this->targetDate)),
144 'total_amount' => '150',
145 'financial_type_id' => 2,
146 'non_deductible_amount' => '10',
147 'fee_amount' => '5',
148 'net_amount' => '145',
149 'source' => 'SSF',
150 'contribution_status_id' => 2,
151 ));
152 }
153
154 public function scheduleForDues() {
155 $this->schedule->mapping_id = CRM_Contribute_ActionMapping_ByType::MAPPING_ID;
156 $this->schedule->start_action_date = 'receive_date';
157 $this->schedule->entity_value = CRM_Utils_Array::implodePadded(array(1));
158 $this->schedule->entity_status = CRM_Utils_Array::implodePadded(array(1));
159 }
160
161 public function scheduleForDonation() {
162 $this->schedule->mapping_id = CRM_Contribute_ActionMapping_ByType::MAPPING_ID;
163 $this->schedule->start_action_date = 'receive_date';
164 $this->schedule->entity_value = CRM_Utils_Array::implodePadded(array(2));
165 $this->schedule->entity_status = CRM_Utils_Array::implodePadded(NULL);
166 }
167
168 public function scheduleForAny() {
169 $this->schedule->mapping_id = CRM_Contribute_ActionMapping_ByType::MAPPING_ID;
170 $this->schedule->start_action_date = 'receive_date';
171 $this->schedule->entity_value = CRM_Utils_Array::implodePadded(NULL);
172 $this->schedule->entity_status = CRM_Utils_Array::implodePadded(NULL);
173 }
174
175 public function scheduleForSoftCreditor() {
176 $this->schedule->mapping_id = CRM_Contribute_ActionMapping_ByType::MAPPING_ID;
177 $this->schedule->start_action_date = 'receive_date';
178 $this->schedule->entity_value = CRM_Utils_Array::implodePadded(NULL);
179 $this->schedule->entity_status = CRM_Utils_Array::implodePadded(NULL);
180 $this->schedule->limit_to = 1;
181 $this->schedule->recipient = 'soft_credit_type';
182 $this->schedule->recipient_listing = CRM_Utils_Array::implodePadded(array(3));
183 }
184
185}