3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviUnitTestCase.php';
30 class CRM_Contribute_ActionMapping_ByTypeTest
extends \Civi\ActionSchedule\AbstractMappingTest
{
33 * Generate a list of test cases, where each is a distinct combination of
34 * data, schedule-rules, and schedule results.
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
45 public function createTestCases() {
49 '2015-02-01 00:00:00',
50 'addAliceDues addBobDonation scheduleForDues startOnTime useHelloFirstName',
53 'time' => '2015-02-01 00:00:00',
54 'to' => array('alice@example.org'),
55 'subject' => '/Hello, Alice.*via subject/',
61 '2015-02-01 00:00:00',
62 'addAliceDues addBobDonation scheduleForAny startOnTime useHelloFirstName',
65 'time' => '2015-02-01 00:00:00',
66 'to' => array('alice@example.org'),
67 'subject' => '/Hello, Alice.*via subject/',
70 'time' => '2015-02-01 00:00:00',
71 'to' => array('bob@example.org'),
72 'subject' => '/Hello, Bob.*via subject/',
78 '2015-02-02 00:00:00',
79 'addAliceDues addBobDonation scheduleForDonation startWeekBefore repeatTwoWeeksAfter useHelloFirstName',
82 'time' => '2015-01-26 00:00:00',
83 'to' => array('bob@example.org'),
84 'subject' => '/Hello, Bob.*via subject/',
87 'time' => '2015-02-02 00:00:00',
88 'to' => array('bob@example.org'),
89 'subject' => '/Hello, Bob.*via subject/',
92 'time' => '2015-02-09 00:00:00',
93 'to' => array('bob@example.org'),
94 'subject' => '/Hello, Bob.*via subject/',
97 'time' => '2015-02-16 00:00:00',
98 'to' => array('bob@example.org'),
99 'subject' => '/Hello, Bob.*via subject/',
105 '2015-02-03 00:00:00',
106 'addAliceDues addBobDonation scheduleForSoftCreditor startWeekAfter useHelloFirstName',
109 'time' => '2015-02-10 00:00:00',
110 'to' => array('carol@example.org'),
111 'subject' => '/Hello, Carol.*via subject/',
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',
127 'net_amount' => '95',
129 'contribution_status_id' => 1,
130 'soft_credit' => array(
132 'contact_id' => $this->contacts
['carol']['id'],
134 'soft_credit_type_id' => 3,
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',
148 'net_amount' => '145',
150 'contribution_status_id' => 2,
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));
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);
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);
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));