3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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 +--------------------------------------------------------------------+
29 * Class CRM_Core_Payment_BaseIPNTest
32 class CRM_Core_Payment_BaseIPNTest
extends CiviUnitTestCase
{
34 protected $_financialTypeId;
35 protected $_contributionParams;
36 protected $_contactId;
37 protected $_contributionId;
38 protected $_participantId;
41 protected $_processorId;
42 protected $_contributionRecurParams;
43 protected $_paymentProcessor;
46 * Parameters to create a membership.
50 protected $_membershipParams = [];
55 * @var CRM_Core_Payment_BaseIPN
59 protected $_membershipId;
67 protected $_membershipTypeID;
72 protected $_membershipStatusID;
73 public $DBResetRequired = FALSE;
78 public function setUp() {
80 $this->_processorId
= $this->paymentProcessorAuthorizeNetCreate(['is_test' => 0]);
81 $this->input
= $this->ids
= $this->objects
= [];
82 $this->IPN
= new CRM_Core_Payment_AuthorizeNetIPN($this->input
);
84 $this->_contactId
= $this->individualCreate();
85 $this->ids
['contact'] = $this->_contactId
;
86 $this->_financialTypeId
= 1;
88 $this->_contributionParams
= [
89 'contact_id' => $this->_contactId
,
90 'financial_type_id' => $this->_financialTypeId
,
91 'receive_date' => date('Ymd'),
92 'total_amount' => 150.00,
93 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885',
95 'contribution_recur_id' => $this->_recurId
,
96 'contribution_status_id' => 2,
98 $contribution = $this->callAPISuccess('contribution', 'create', $this->_contributionParams
);
99 $this->_contributionId
= $contribution['id'];
101 $contribution = new CRM_Contribute_BAO_Contribution();
102 $contribution->id
= $this->_contributionId
;
103 $contribution->find(TRUE);
104 $this->objects
['contribution'] = $contribution;
108 * Tear down after class.
110 public function tearDown() {
111 $this->quickCleanUpFinancialEntities();
112 CRM_Member_PseudoConstant
::membershipType(NULL, TRUE);
113 CRM_Member_PseudoConstant
::membershipStatus(NULL, NULL, 'name', TRUE);
117 * Test the LoadObjects function with recurring membership data.
119 public function testLoadMembershipObjects() {
120 $this->_setUpMembershipObjects();
121 $this->_setUpRecurringContribution();
122 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
123 $this->assertFalse(empty($this->objects
['membership']));
124 $this->assertArrayHasKey($this->_membershipTypeID
, $this->objects
['membership']);
125 $this->assertTrue(is_a($this->objects
['membership'][$this->_membershipTypeID
], 'CRM_Member_BAO_Membership'));
126 $this->assertTrue(is_a($this->objects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
127 $this->assertFalse(empty($this->objects
['contributionRecur']));
128 $this->assertFalse(empty($this->objects
['paymentProcessor']));
132 * Test the LoadObjects function with recurring membership data.
134 public function testLoadMembershipObjectsNoLeakage() {
135 $this->_setUpMembershipObjects();
136 $this->_setUpRecurringContribution();
137 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
138 $this->assertEquals('Anthony', $this->objects
['contact']->first_name
);
140 $this->ids
['contact'] = $this->_contactId
= $this->individualCreate([
141 'first_name' => 'Donald',
142 'last_name' => 'Duck',
143 'email' => 'the-don@duckville.com',
145 $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_contributionParams
, ['invoice_id' => 'abc']));
146 $this->_contributionId
= $contribution['id'];
147 $this->_setUpMembershipObjects();
148 $this->input
['invoiceID'] = 'abc';
149 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
150 $this->assertEquals('Donald', $this->objects
['contact']->first_name
);
154 * Test the LoadObjects function with recurring membership data.
156 public function testLoadMembershipObjectsLoadAll() {
157 $this->_setUpMembershipObjects();
158 $this->_setUpRecurringContribution();
159 unset($this->ids
['membership']);
160 $contribution = new CRM_Contribute_BAO_Contribution();
161 $contribution->id
= $this->_contributionId
;
162 $contribution->find(TRUE);
163 $contribution->loadRelatedObjects($this->input
, $this->ids
, TRUE);
164 $this->assertFalse(empty($contribution->_relatedObjects
['membership']));
165 $this->assertArrayHasKey($this->_membershipTypeID
, $contribution->_relatedObjects
['membership']);
166 $this->assertTrue(is_a($contribution->_relatedObjects
['membership'][$this->_membershipTypeID
], 'CRM_Member_BAO_Membership'));
167 $this->assertTrue(is_a($contribution->_relatedObjects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
168 $this->assertFalse(empty($contribution->_relatedObjects
['contributionRecur']));
169 $this->assertFalse(empty($contribution->_relatedObjects
['paymentProcessor']));
173 * Test the LoadObjects function with recurring membership data.
175 public function testsendMailMembershipObjects() {
176 $this->_setUpMembershipObjects();
178 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
179 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
180 $this->assertTrue(is_array($msg), "Message returned as an array in line");
181 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
182 $this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
183 $this->assertContains('Membership Type: General', $msg['body']);
187 * Test the LoadObjects function data does not leak.
189 * If more than one iteration takes place the variables should not leak.
191 public function testSendMailMembershipObjectsNoLeakage() {
192 $this->_setUpMembershipObjects();
194 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
195 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
196 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
197 $this->assertContains('Membership Type: General', $msg['body']);
199 $this->ids
['contact'] = $this->_contactId
= $this->individualCreate(['prefix_id' => 'Dr.', 'first_name' => 'Donald', 'last_name' => 'Duck', 'email' => 'the-don@duckville.com']);
200 $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_contributionParams
, ['invoice_id' => 'abc']));
201 $this->_contributionId
= $contribution['id'];
203 $this->_membershipTypeID
= $this->membershipTypeCreate(['name' => 'Fowl']);
204 $this->_setUpMembershipObjects();
205 $this->input
['invoiceID'] = 'abc';
206 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
207 $this->assertEquals('Donald', $this->objects
['contact']->first_name
);
208 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
209 $this->assertEquals('Dr. Donald Duck II', $msg['to']);
210 $this->assertContains('Membership Type: Fowl', $msg['body']);
214 * Test the LoadObjects function with recurring membership data.
216 public function testsendMailMembershipWithoutLoadObjects() {
217 $this->_setUpMembershipObjects();
219 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
220 $this->assertTrue(is_array($msg), "Message returned as an array in line" . __LINE__
);
221 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
222 $this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
223 $this->assertContains('Membership Type: General', $msg['body']);
227 * Test that loadObjects works with participant values.
229 public function testLoadParticipantObjects() {
230 $this->_setUpParticipantObjects();
231 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
232 $this->assertFalse(empty($this->objects
['participant']));
233 $this->assertTrue(is_a($this->objects
['participant'], 'CRM_Event_BAO_Participant'));
234 $this->assertTrue(is_a($this->objects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
235 $this->assertFalse(empty($this->objects
['event']));
236 $this->assertTrue(is_a($this->objects
['event'], 'CRM_Event_BAO_Event'));
237 $this->assertTrue(is_a($this->objects
['contribution'], 'CRM_Contribute_BAO_Contribution'));
238 $this->assertFalse(empty($this->objects
['event']->id
));
242 * Test the LoadObjects function with a participant.
244 public function testComposeMailParticipant() {
245 $this->_setUpParticipantObjects();
246 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
248 $this->assertFalse(empty($this->objects
['event']));
249 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
250 $this->assertContains('registration has been received and your status has been updated to Attended.', $msg['body']);
251 $this->assertContains('Annual CiviCRM meet', $msg['html']);
256 public function testComposeMailParticipantObjects() {
257 $this->_setUpParticipantObjects();
259 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
260 $this->assertTrue(is_array($msg), "Message returned as an array in line" . __LINE__
);
261 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
262 $this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
263 $this->assertContains('Thank you for your participation', $msg['body']);
267 * Test the LoadObjects function with recurring membership data.
269 public function testsendMailParticipantObjectsCheckLog() {
270 $this->_setUpParticipantObjects();
272 $mut = new CiviMailUtils($this, TRUE);
273 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
274 $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, FALSE);
276 'Thank you for your participation',
277 'Annual CiviCRM meet',
278 'Mr. Anthony Anderson II',
284 * Test the LoadObjects function with recurring membership data.
286 public function testsendMailParticipantObjectsNoMail() {
287 $this->_setUpParticipantObjects();
288 $event = new CRM_Event_BAO_Event();
289 $event->id
= $this->_eventId
;
290 $event->is_email_confirm
= FALSE;
293 $tablesToTruncate = [
294 'civicrm_mailing_spool',
296 $this->quickCleanup($tablesToTruncate, FALSE);
297 $mut = new CiviMailUtils($this, TRUE);
298 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
299 $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, FALSE);
300 $mut->assertMailLogEmpty('no mail should have been send as event set to no confirm');
305 * Test that loadObjects works with participant values.
307 public function testLoadPledgeObjects() {
308 $this->_setUpPledgeObjects();
309 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
310 $this->assertFalse(empty($this->objects
['pledge_payment'][0]));
311 $this->assertTrue(is_a($this->objects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
312 $this->assertTrue(is_a($this->objects
['contribution'], 'CRM_Contribute_BAO_Contribution'));
313 $this->assertTrue(is_a($this->objects
['pledge_payment'][0], 'CRM_Pledge_BAO_PledgePayment'));
314 $this->assertFalse(empty($this->objects
['pledge_payment'][0]->id
));
315 $this->assertEquals($this->_financialTypeId
, $this->objects
['financialType']->id
);
316 $this->assertEquals($this->_processorId
, $this->objects
['paymentProcessor']['id']);
317 $this->assertEquals($this->_contributionId
, $this->objects
['contribution']->id
);
318 $this->assertEquals($this->_contactId
, $this->objects
['contact']->id
);
319 $this->assertEquals($this->_pledgeId
, $this->objects
['pledge_payment'][0]->pledge_id
);
323 * Test that loadObjects works with participant values.
325 public function testLoadPledgeObjectsInvalidPledgeID() {
326 $this->_setUpPledgeObjects();
327 $this->ids
['pledge_payment'][0] = 0;
328 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
329 $this->assertArrayHasKey('error_message', $result);
330 $this->assertArrayNotHasKey('pledge_payment', $this->objects
);
331 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
332 $this->ids
['pledge_payment'][0] = NULL;
333 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
334 $this->assertArrayHasKey('error_message', $result);
335 $this->assertArrayNotHasKey('pledge_payment', $this->objects
);
336 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
337 $this->ids
['pledge_payment'][0] = '';
338 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
339 $this->assertArrayHasKey('error_message', $result);
340 $this->assertArrayNotHasKey('pledge_payment', $this->objects
);
341 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
343 $this->ids
['pledge_payment'][0] = 999;
344 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, $this->_processorId
, ['return_error' => 1]);
345 $this->assertArrayHasKey('error_message', $result);
346 $this->assertEquals('Could not find pledge payment record: 999', $result['error_message']);
350 * Test the LoadObjects function with a pledge.
352 public function testsendMailPledge() {
353 $this->_setUpPledgeObjects();
355 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, NULL);
356 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
357 $this->assertContains('Contribution Information', $msg['html']);
361 * Test that an error is returned if required set & no contribution page.
363 public function testRequiredWithoutProcessorID() {
364 $this->_setUpPledgeObjects();
365 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
366 $this->assertArrayHasKey('error_message', $result);
367 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
368 // error is only returned if $required set to True
369 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, NULL, ['return_error' => 1]);
370 $this->assertFalse(is_array($result));
371 //check that error is not returned if error checking not set
372 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['log_error' => 1]);
373 $this->assertFalse(is_array($result));
377 * Test that an error is not if required set & no processor ID
379 public function testRequiredWithContributionPage() {
380 $this->_setUpContributionObjects(TRUE);
381 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
382 $this->assertEquals(1, $result['is_error']);
387 * Test that if part of $input the payment processor loads OK.
389 * It's preferable to pass it in as it cannot be correctly calculated.
391 public function testPaymentProcessorLoadsAsParam() {
392 $this->_setUpContributionObjects();
393 $this->input
= array_merge($this->input
, ['payment_processor_id' => $this->_processorId
]);
394 $this->assertTrue($this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]));
398 * Test that an error is returned if required set & contribution page exists
400 public function testRequiredWithContributionPageError() {
401 $this->_setUpContributionObjects();
402 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
403 $this->assertArrayHasKey('error_message', $result);
404 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
405 // error is only returned if $required set to True
406 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, NULL, ['return_error' => 1]);
407 $this->assertFalse(is_array($result));
408 //check that error is not returned if error checking not set
409 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['log_error' => 1]);
410 $this->assertFalse(is_array($result));
413 public function testThatCancellingEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities() {
414 $this->_setUpParticipantObjects('Pending from incomplete transaction');
415 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
416 $additionalParticipantId = $this->participantCreate([
417 'event_id' => $this->_eventId
,
418 'registered_by_id' => $this->_participantId
,
419 'status_id' => 'Pending from incomplete transaction',
422 $transaction = new CRM_Core_Transaction();
423 $this->IPN
->cancelled($this->objects
, $transaction);
425 $cancelledParticipantsCount = civicrm_api3('Participant', 'get', [
427 'id' => ['IN' => [$this->_participantId
, $additionalParticipantId]],
428 'status_id' => 'Cancelled',
430 $this->assertEquals(2, $cancelledParticipantsCount);
432 $cancelledActivatesCount = civicrm_api3('Activity', 'get', [
434 'activity_type_id' => 'Event Registration',
435 'subject' => ['LIKE' => '%Cancelled%'],
436 'source_record_id' => ['IN' => [$this->_participantId
, $additionalParticipantId]],
439 $this->assertEquals(2, $cancelledActivatesCount['count']);
442 public function testThatFailedEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities() {
443 $this->_setUpParticipantObjects('Pending from incomplete transaction');
444 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
445 $additionalParticipantId = $this->participantCreate([
446 'event_id' => $this->_eventId
,
447 'registered_by_id' => $this->_participantId
,
448 'status_id' => 'Pending from incomplete transaction',
451 $transaction = new CRM_Core_Transaction();
452 $this->IPN
->failed($this->objects
, $transaction);
454 $cancelledParticipantsCount = civicrm_api3('Participant', 'get', [
456 'id' => ['IN' => [$this->_participantId
, $additionalParticipantId]],
457 'status_id' => 'Cancelled',
459 $this->assertEquals(2, $cancelledParticipantsCount);
461 $cancelledActivatesCount = civicrm_api3('Activity', 'get', [
463 'activity_type_id' => 'Event Registration',
464 'subject' => ['LIKE' => '%Cancelled%'],
465 'source_record_id' => ['IN' => [$this->_participantId
, $additionalParticipantId]],
468 $this->assertEquals(2, $cancelledActivatesCount['count']);
472 * Prepare for contribution Test - involving only contribution objects
474 * @param bool $contributionPage
476 public function _setUpContributionObjects($contributionPage = FALSE) {
478 $contribution = new CRM_Contribute_BAO_Contribution();
479 $contribution->id
= $this->_contributionId
;
480 $contribution->find(TRUE);
481 $contributionPageID = NULL;
483 if (!empty($contributionPage)) {
484 $dao = new CRM_Core_DAO();
485 $contribution_page = $dao->createTestObject('CRM_Contribute_DAO_ContributionPage');
486 $contribution_page->payment_processor
= 1;
487 $contribution_page->save();
488 $contribution->contribution_page_id
= $contributionPageID = $contribution_page->id
;
489 //for unknown reasons trying to do a find & save on a contribution with a receive_date set
490 // doesn't work. This seems of minimal relevance to this test so ignoring
491 // note that in tests it worked sometimes & not others - dependent on which other tests run.
492 // running all CRM_Core tests caused failure as did just the single failing test. But running
493 // just this class succeeds - because it actually doesn't do a mysql update on the following save
495 unset($contribution->receive_date
);
496 $contribution->save();
499 $this->objects
['contribution'] = $contribution;
501 'component' => 'contribute',
502 'contribution_page_id' => $contributionPageID,
503 'total_amount' => 110.00,
504 'invoiceID' => "c8acb91e080ad7777a2adc119c192885",
505 'contactID' => $this->_contactId
,
506 'contributionID' => $this->objects
['contribution']->id
,
511 * Prepare for membership test.
513 public function _setUpMembershipObjects() {
515 if (!$this->_membershipTypeID
) {
516 $this->_membershipTypeID
= $this->membershipTypeCreate();
518 if (!$this->_membershipStatusID
) {
519 $this->_membershipStatusID
= $this->membershipStatusCreate('test status');
522 catch (Exception
$e) {
523 echo $e->getMessage();
525 CRM_Member_PseudoConstant
::membershipType($this->_membershipTypeID
, TRUE);
526 CRM_Member_PseudoConstant
::membershipStatus(NULL, NULL, 'name', TRUE);
527 $this->_membershipParams
= [
528 'contact_id' => $this->_contactId
,
529 'membership_type_id' => $this->_membershipTypeID
,
530 'join_date' => '2009-01-21',
531 'start_date' => '2009-01-21',
532 'end_date' => '2009-12-21',
533 'source' => 'Payment',
535 'status_id' => $this->_membershipStatusID
,
539 $membership = $this->callAPISuccess('membership', 'create', $this->_membershipParams
);
540 if ($this->objects
['contribution']->id
!= $this->_contributionId
) {
541 $contribution = new CRM_Contribute_BAO_Contribution();
542 $contribution->id
= $this->_contributionId
;
543 $contribution->find(TRUE);
544 $this->objects
= ['contribution' => $contribution];
546 $this->_membershipId
= $membership['id'];
547 //we'll create membership payment here because to make setup more re-usable
548 $this->callAPISuccess('membership_payment', 'create', [
549 'contribution_id' => $this->_contributionId
,
550 'membership_id' => $this->_membershipId
,
554 'component' => 'contribute',
555 'total_amount' => 150.00,
556 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
557 'contactID' => $this->_contactId
,
558 'contributionID' => $this->_contributionId
,
559 'membershipID' => $this->_membershipId
,
562 $this->ids
['membership'] = $this->_membershipId
;
565 public function _setUpRecurringContribution() {
566 $this->_contributionRecurParams
= [
567 'contact_id' => $this->_contactId
,
570 'frequency_unit' => 'week',
571 'frequency_interval' => 1,
573 'start_date' => date('Ymd'),
574 'create_date' => date('Ymd'),
575 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885',
576 'contribution_status_id' => 2,
577 'financial_type_id' => $this->_financialTypeId
,
579 'payment_processor_id' => $this->_processorId
,
581 $this->_recurId
= $this->callAPISuccess('contribution_recur', 'create', $this->_contributionRecurParams
);
582 $this->_recurId
= $this->_recurId
['id'];
583 $this->input
['contributionRecurId'] = $this->_recurId
;
584 $this->ids
['contributionRecur'] = $this->_recurId
;
588 * Set up participant requirements for test.
590 * @param string $participantStatus
591 * The participant to create status
593 public function _setUpParticipantObjects($participantStatus = 'Attended') {
594 $event = $this->eventCreate(['is_email_confirm' => 1]);
596 $this->_eventId
= $event['id'];
597 $this->_participantId
= $this->participantCreate([
598 'event_id' => $this->_eventId
,
599 'contact_id' => $this->_contactId
,
600 'status_id' => $participantStatus,
603 $this->callAPISuccess('participant_payment', 'create', [
604 'contribution_id' => $this->_contributionId
,
605 'participant_id' => $this->_participantId
,
608 $contribution = new CRM_Contribute_BAO_Contribution();
609 $contribution->id
= $this->_contributionId
;
610 $contribution->find();
611 $this->objects
['contribution'] = $contribution;
613 'component' => 'event',
614 'total_amount' => 150.00,
615 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
616 'contactID' => $this->_contactId
,
617 'contributionID' => $contribution->id
,
618 'participantID' => $this->_participantId
,
621 $this->ids
['participant'] = $this->_participantId
;
622 $this->ids
['event'] = $this->_eventId
;
626 * Set up participant requirements for test.
628 public function _setUpPledgeObjects() {
629 $this->_pledgeId
= $this->pledgeCreate(['contact_id' => $this->_contactId
]);
630 //we'll create membership payment here because to make setup more re-usable
631 $pledgePayment = $this->callAPISuccess('pledge_payment', 'create', [
633 'pledge_id' => $this->_pledgeId
,
634 'contribution_id' => $this->_contributionId
,
636 'actual_amount' => 50,
640 'component' => 'contribute',
641 'total_amount' => 150.00,
642 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
643 'contactID' => $this->_contactId
,
644 'contributionID' => $this->_contributionId
,
645 'pledgeID' => $this->_pledgeId
,
648 $this->ids
['pledge_payment'][] = $pledgePayment['id'];