3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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 +--------------------------------------------------------------------+
29 * Class CRM_Core_Payment_BaseIPNTest
31 class CRM_Core_Payment_BaseIPNTest
extends CiviUnitTestCase
{
33 protected $_financialTypeId;
34 protected $_contributionParams;
35 protected $_contactId;
36 protected $_contributionId;
37 protected $_participantId;
40 protected $_processorId;
41 protected $_contributionRecurParams;
42 protected $_paymentProcessor;
45 * Parameters to create a membership.
49 protected $_membershipParams = array();
54 * @var CRM_Core_Payment_BaseIPN
58 protected $_membershipId;
66 protected $_membershipTypeID;
71 protected $_membershipStatusID;
72 public $DBResetRequired = FALSE;
77 public function setUp() {
79 $this->_processorId
= $this->paymentProcessorAuthorizeNetCreate(array('is_test' => 0));
80 $this->input
= $this->ids
= $this->objects
= array();
81 $this->IPN
= new CRM_Core_Payment_AuthorizeNetIPN($this->input
);
83 $this->_contactId
= $this->individualCreate();
84 $this->ids
['contact'] = $this->_contactId
;
85 $this->_financialTypeId
= 1;
87 $this->_contributionParams
= array(
88 'contact_id' => $this->_contactId
,
89 'financial_type_id' => $this->_financialTypeId
,
90 'receive_date' => date('Ymd'),
91 'total_amount' => 150.00,
92 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885',
94 'contribution_recur_id' => $this->_recurId
,
95 'contribution_status_id' => 2,
97 $contribution = $this->callAPISuccess('contribution', 'create', $this->_contributionParams
);
98 $this->_contributionId
= $contribution['id'];
100 $contribution = new CRM_Contribute_BAO_Contribution();
101 $contribution->id
= $this->_contributionId
;
102 $contribution->find(TRUE);
103 $this->objects
['contribution'] = $contribution;
107 * Tear down after class.
109 public function tearDown() {
110 $this->quickCleanUpFinancialEntities();
111 CRM_Member_PseudoConstant
::membershipType(NULL, TRUE);
112 CRM_Member_PseudoConstant
::membershipStatus(NULL, NULL, 'name', TRUE);
116 * Test the LoadObjects function with recurring membership data.
118 public function testLoadMembershipObjects() {
119 $this->_setUpMembershipObjects();
120 $this->_setUpRecurringContribution();
121 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
122 $this->assertFalse(empty($this->objects
['membership']));
123 $this->assertArrayHasKey($this->_membershipTypeID
, $this->objects
['membership']);
124 $this->assertTrue(is_a($this->objects
['membership'][$this->_membershipTypeID
], 'CRM_Member_BAO_Membership'));
125 $this->assertTrue(is_a($this->objects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
126 $this->assertFalse(empty($this->objects
['contributionRecur']));
127 $this->assertFalse(empty($this->objects
['paymentProcessor']));
131 * Test the LoadObjects function with recurring membership data.
133 public function testLoadMembershipObjectsNoLeakage() {
134 $this->_setUpMembershipObjects();
135 $this->_setUpRecurringContribution();
136 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
137 $this->assertEquals('Anthony', $this->objects
['contact']->first_name
);
139 $this->ids
['contact'] = $this->_contactId
= $this->individualCreate(array(
140 'first_name' => 'Donald',
141 'last_name' => 'Duck',
142 'email' => 'the-don@duckville.com,
144 $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_contributionParams
, array('invoice_id' => 'abc')));
145 $this->_contributionId
= $contribution['id'];
146 $this->_setUpMembershipObjects();
147 $this->input
['invoiceID'] = 'abc';
148 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
149 $this->assertEquals('Donald', $this->objects
['contact']->first_name
);
153 * Test the LoadObjects function with recurring membership data.
155 public function testLoadMembershipObjectsLoadAll() {
156 $this->_setUpMembershipObjects();
157 $this->_setUpRecurringContribution();
158 unset($this->ids
['membership']);
159 $contribution = new CRM_Contribute_BAO_Contribution();
160 $contribution->id
= $this->_contributionId
;
161 $contribution->find(TRUE);
162 $contribution->loadRelatedObjects($this->input
, $this->ids
, TRUE);
163 $this->assertFalse(empty($contribution->_relatedObjects
['membership']));
164 $this->assertArrayHasKey($this->_membershipTypeID
, $contribution->_relatedObjects
['membership']);
165 $this->assertTrue(is_a($contribution->_relatedObjects
['membership'][$this->_membershipTypeID
], 'CRM_Member_BAO_Membership'));
166 $this->assertTrue(is_a($contribution->_relatedObjects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
167 $this->assertFalse(empty($contribution->_relatedObjects
['contributionRecur']));
168 $this->assertFalse(empty($contribution->_relatedObjects
['paymentProcessor']));
172 * Test the LoadObjects function with recurring membership data.
174 public function testsendMailMembershipObjects() {
175 $this->_setUpMembershipObjects();
177 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
178 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
179 $this->assertTrue(is_array($msg), "Message returned as an array in line");
180 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
181 $this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
182 $this->assertContains('Membership Type: General', $msg['body']);
186 * Test the LoadObjects function data does not leak.
188 * If more than one iteration takes place the variables should not leak.
190 public function testSendMailMembershipObjectsNoLeakage() {
191 $this->_setUpMembershipObjects();
193 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
194 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
195 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
196 $this->assertContains('Membership Type: General', $msg['body']);
198 $this->ids
['contact'] = $this->_contactId
= $this->individualCreate(array('prefix_id' => 'Dr.', 'first_name' => 'Donald', 'last_name' => 'Duck', 'email' => 'the-don@duckville.com'));
199 $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_contributionParams
, array('invoice_id' => 'abc')));
200 $this->_contributionId
= $contribution['id'];
202 $this->_membershipTypeID
= $this->membershipTypeCreate(array('name' => 'Fowl'));
203 $this->_setUpMembershipObjects();
204 $this->input
['invoiceID'] = 'abc';
205 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
206 $this->assertEquals('Donald', $this->objects
['contact']->first_name
);
207 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
208 $this->assertEquals('Dr. Donald Duck II', $msg['to']);
209 $this->assertContains('Membership Type: Fowl', $msg['body']);
213 * Test the LoadObjects function with recurring membership data.
215 public function testsendMailMembershipWithoutLoadObjects() {
216 $this->_setUpMembershipObjects();
218 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
219 $this->assertTrue(is_array($msg), "Message returned as an array in line" . __LINE__
);
220 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
221 $this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
222 $this->assertContains('Membership Type: General', $msg['body']);
226 * Test that loadObjects works with participant values.
228 public function testLoadParticipantObjects() {
229 $this->_setUpParticipantObjects();
230 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
231 $this->assertFalse(empty($this->objects
['participant']));
232 $this->assertTrue(is_a($this->objects
['participant'], 'CRM_Event_BAO_Participant'));
233 $this->assertTrue(is_a($this->objects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
234 $this->assertFalse(empty($this->objects
['event']));
235 $this->assertTrue(is_a($this->objects
['event'], 'CRM_Event_BAO_Event'));
236 $this->assertTrue(is_a($this->objects
['contribution'], 'CRM_Contribute_BAO_Contribution'));
237 $this->assertFalse(empty($this->objects
['event']->id
));
241 * Test the LoadObjects function with a participant.
243 public function testComposeMailParticipant() {
244 $this->_setUpParticipantObjects();
245 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
247 $this->assertFalse(empty($this->objects
['event']));
248 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
249 $this->assertContains('registration has been received and your status has been updated to Attended.', $msg['body']);
250 $this->assertContains('Annual CiviCRM meet', $msg['html']);
255 public function testComposeMailParticipantObjects() {
256 $this->_setUpParticipantObjects();
258 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
259 $this->assertTrue(is_array($msg), "Message returned as an array in line" . __LINE__
);
260 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
261 $this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
262 $this->assertContains('Thank you for your participation', $msg['body']);
266 * Test the LoadObjects function with recurring membership data.
268 public function testsendMailParticipantObjectsCheckLog() {
269 $this->_setUpParticipantObjects();
271 require_once 'CiviTest/CiviMailUtils.php';
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);
275 $mut->checkMailLog(array(
276 'Thank you for your participation',
277 'Annual CiviCRM meet',
278 'Mr. Anthony Anderson II',
285 * Test the LoadObjects function with recurring membership data.
287 public function testsendMailParticipantObjectsNoMail() {
288 $this->_setUpParticipantObjects();
289 $event = new CRM_Event_BAO_Event();
290 $event->id
= $this->_eventId
;
291 $event->is_email_confirm
= FALSE;
294 $tablesToTruncate = array(
295 'civicrm_mailing_spool',
297 $this->quickCleanup($tablesToTruncate, FALSE);
298 require_once 'CiviTest/CiviMailUtils.php';
299 $mut = new CiviMailUtils($this, TRUE);
300 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
301 $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, FALSE);
302 $mut->assertMailLogEmpty('no mail should have been send as event set to no confirm');
307 * Test that loadObjects works with participant values.
309 public function testLoadPledgeObjects() {
310 $this->_setUpPledgeObjects();
311 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
312 $this->assertFalse(empty($this->objects
['pledge_payment'][0]));
313 $this->assertTrue(is_a($this->objects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
314 $this->assertTrue(is_a($this->objects
['contribution'], 'CRM_Contribute_BAO_Contribution'));
315 $this->assertTrue(is_a($this->objects
['pledge_payment'][0], 'CRM_Pledge_BAO_PledgePayment'));
316 $this->assertFalse(empty($this->objects
['pledge_payment'][0]->id
));
317 $this->assertEquals($this->_financialTypeId
, $this->objects
['financialType']->id
);
318 $this->assertEquals($this->_processorId
, $this->objects
['paymentProcessor']['id']);
319 $this->assertEquals($this->_contributionId
, $this->objects
['contribution']->id
);
320 $this->assertEquals($this->_contactId
, $this->objects
['contact']->id
);
321 $this->assertEquals($this->_pledgeId
, $this->objects
['pledge_payment'][0]->pledge_id
);
325 * Test that loadObjects works with participant values.
327 public function testLoadPledgeObjectsInvalidPledgeID() {
328 $this->_setUpPledgeObjects();
329 $this->ids
['pledge_payment'][0] = 0;
330 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, array('return_error' => 1));
331 $this->assertArrayHasKey('error_message', $result);
332 $this->assertArrayNotHasKey('pledge_payment', $this->objects
);
333 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
334 $this->ids
['pledge_payment'][0] = NULL;
335 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, array('return_error' => 1));
336 $this->assertArrayHasKey('error_message', $result);
337 $this->assertArrayNotHasKey('pledge_payment', $this->objects
);
338 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
339 $this->ids
['pledge_payment'][0] = '';
340 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, array('return_error' => 1));
341 $this->assertArrayHasKey('error_message', $result);
342 $this->assertArrayNotHasKey('pledge_payment', $this->objects
);
343 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
345 $this->ids
['pledge_payment'][0] = 999;
346 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, $this->_processorId
, array('return_error' => 1));
347 $this->assertArrayHasKey('error_message', $result);
348 $this->assertEquals('Could not find pledge payment record: 999', $result['error_message']);
352 * Test the LoadObjects function with a pledge.
354 public function testsendMailPledge() {
355 $this->_setUpPledgeObjects();
357 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, NULL);
358 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
359 $this->assertContains('Contribution Information', $msg['html']);
363 * Test that an error is returned if required set & no contribution page.
365 public function testRequiredWithoutProcessorID() {
366 $this->_setUpPledgeObjects();
367 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, array('return_error' => 1));
368 $this->assertArrayHasKey('error_message', $result);
369 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
370 // error is only returned if $required set to True
371 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, NULL, array('return_error' => 1));
372 $this->assertFalse(is_array($result));
373 //check that error is not returned if error checking not set
374 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, array('log_error' => 1));
375 $this->assertFalse(is_array($result));
379 * Test that an error is not if required set & no processor ID
381 public function testRequiredWithContributionPage() {
382 $this->_setUpContributionObjects(TRUE);
383 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, array('return_error' => 1));
384 $this->assertEquals(1, $result['is_error']);
389 * Test that if part of $input the payment processor loads OK.
391 * It's preferable to pass it in as it cannot be correctly calculated.
393 public function testPaymentProcessorLoadsAsParam() {
394 $this->_setUpContributionObjects();
395 $this->input
= array_merge($this->input
, array('payment_processor_id' => $this->_processorId
));
396 $this->assertTrue($this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, array('return_error' => 1)));
400 * Test that an error is returned if required set & contribution page exists
402 public function testRequiredWithContributionPageError() {
403 $this->_setUpContributionObjects();
404 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, array('return_error' => 1));
405 $this->assertArrayHasKey('error_message', $result);
406 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
407 // error is only returned if $required set to True
408 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, NULL, array('return_error' => 1));
409 $this->assertFalse(is_array($result));
410 //check that error is not returned if error checking not set
411 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, array('log_error' => 1));
412 $this->assertFalse(is_array($result));
415 /* @codingStandardsIgnoreStart
416 * Test calls main functions in sequence per 'main' - I had hoped to test the functions more
417 * fully but the calls to the POST happen in more than one function
418 * keeping this as good example of data to bring back to life later
420 public function testMainFunctionActions() {
421 $ids = $objects = array( );
422 $input['component'] = 'Contribute';
423 $postedParams = array(
424 'x_response_code' => 1,
425 'x_response_reason_code' => 1,
426 'x_response_reason_text' => 'This transaction has been approved.',
428 'x_auth_code' => 140454,
429 'x_trans_id' => 4353599599,
431 'x_card_type' => 'American Express',
432 'x_account_number' => 'XXXX2701',
433 'x_first_name' => 'Arthur',
434 'x_last_name' => 'Jacobs',
436 'x_address' => '866 2166th St SN',
437 'x_city' => 'Edwardstown',
444 'x_invoice_num' => 'a9fb56c24576lk4c9490f6',
445 'x_description' => 'my desc',
446 'x_type' => 'auth_capture',
448 'x_ship_to_first_name' => null,
449 'x_ship_to_last_name' => null,
450 'x_ship_to_company' => null,
451 'x_ship_to_address' => null,
452 'x_ship_to_city' => null,
453 'x_ship_to_state' => null,
454 'x_ship_to_zip' => null,
455 'x_ship_to_country' => null,
460 'x_tax_exempt' => FALSE,
462 'x_MD5_Hash' => '069ECAD13C8E15AC205CDF92B8B58CC7',
463 'x_cvv2_resp_code' => null,
464 'x_cavv_response' => null,
465 'x_test_request' => false,
466 'description' => 'my description'
468 $this->IPN->getInput( $input, $ids );
469 $this->IPN->getIDs( $ids, $input );
471 CRM_Core_Error::debug_var( '$ids', $ids );
472 CRM_Core_Error::debug_var( '$input', $input );
474 $paymentProcessorID = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_PaymentProcessorType',
475 'AuthNet', 'id', 'name' );
477 if ( ! $this->IPN->validateData( $input, $ids, $objects, true, $paymentProcessorID ) ) {
481 if ( $component == 'contribute' && $ids['contributionRecur'] ) {
482 // check if first contribution is completed, else complete first contribution
484 if ( $objects['contribution']->contribution_status_id == 1 ) {
487 return $this->IPN->recur( $input, $ids, $objects, $first );
490 @codingStandardsIgnoreEnd */
493 * Prepare for contribution Test - involving only contribution objects
495 * @param bool $contributionPage
497 public function _setUpContributionObjects($contributionPage = FALSE) {
499 $contribution = new CRM_Contribute_BAO_Contribution();
500 $contribution->id
= $this->_contributionId
;
501 $contribution->find(TRUE);
502 $contributionPageID = NULL;
504 if (!empty($contributionPage)) {
505 $dao = new CRM_Core_DAO();
506 $contribution_page = $dao->createTestObject('CRM_Contribute_DAO_ContributionPage');
507 $contribution_page->payment_processor
= 1;
508 $contribution_page->save();
509 $contribution->contribution_page_id
= $contributionPageID = $contribution_page->id
;
510 //for unknown reasons trying to do a find & save on a contribution with a receive_date set
511 // doesn't work. This seems of minimal relevance to this test so ignoring
512 // note that in tests it worked sometimes & not others - dependent on which other tests run.
513 // running all CRM_Core tests caused failure as did just the single failing test. But running
514 // just this class succeeds - because it actually doesn't do a mysql update on the following save
516 unset($contribution->receive_date
);
517 $contribution->save();
520 $this->objects
['contribution'] = $contribution;
521 $this->input
= array(
522 'component' => 'contribute',
523 'contribution_page_id' => $contributionPageID,
524 'total_amount' => 110.00,
525 'invoiceID' => "c8acb91e080ad7777a2adc119c192885",
526 'contactID' => $this->_contactId
,
527 'contributionID' => $this->objects
['contribution']->id
,
532 * Prepare for membership test.
534 public function _setUpMembershipObjects() {
536 if (!$this->_membershipTypeID
) {
537 $this->_membershipTypeID
= $this->membershipTypeCreate();
539 if (!$this->_membershipStatusID
) {
540 $this->_membershipStatusID
= $this->membershipStatusCreate('test status');
543 catch (Exception
$e) {
544 echo $e->getMessage();
546 CRM_Member_PseudoConstant
::membershipType($this->_membershipTypeID
, TRUE);
547 CRM_Member_PseudoConstant
::membershipStatus(NULL, NULL, 'name', TRUE);
548 $this->_membershipParams
= array(
549 'contact_id' => $this->_contactId
,
550 'membership_type_id' => $this->_membershipTypeID
,
551 'join_date' => '2009-01-21',
552 'start_date' => '2009-01-21',
553 'end_date' => '2009-12-21',
554 'source' => 'Payment',
556 'status_id' => $this->_membershipStatusID
,
560 $membership = $this->callAPISuccess('membership', 'create', $this->_membershipParams
);
561 if ($this->objects
['contribution']->id
!= $this->_contributionId
) {
562 $contribution = new CRM_Contribute_BAO_Contribution();
563 $contribution->id
= $this->_contributionId
;
564 $contribution->find(TRUE);
565 $this->objects
= array('contribution' => $contribution);
567 $this->_membershipId
= $membership['id'];
568 //we'll create membership payment here because to make setup more re-usable
569 $this->callAPISuccess('membership_payment', 'create', array(
570 'contribution_id' => $this->_contributionId
,
571 'membership_id' => $this->_membershipId
,
574 $this->input
= array(
575 'component' => 'contribute',
576 'total_amount' => 150.00,
577 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
578 'contactID' => $this->_contactId
,
579 'contributionID' => $this->_contributionId
,
580 'membershipID' => $this->_membershipId
,
583 $this->ids
['membership'] = $this->_membershipId
;
586 public function _setUpRecurringContribution() {
587 $this->_contributionRecurParams
= array(
588 'contact_id' => $this->_contactId
,
591 'frequency_unit' => 'week',
592 'frequency_interval' => 1,
594 'start_date' => date('Ymd'),
595 'create_date' => date('Ymd'),
596 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885',
597 'contribution_status_id' => 2,
598 'financial_type_id' => $this->_financialTypeId
,
600 'payment_processor_id' => $this->_processorId
,
602 $this->_recurId
= $this->callAPISuccess('contribution_recur', 'create', $this->_contributionRecurParams
);
603 $this->_recurId
= $this->_recurId
['id'];
604 $this->input
['contributionRecurId'] = $this->_recurId
;
605 $this->ids
['contributionRecur'] = $this->_recurId
;
609 * Set up participant requirements for test.
611 public function _setUpParticipantObjects() {
612 $event = $this->eventCreate(array('is_email_confirm' => 1));
614 $this->_eventId
= $event['id'];
615 $this->_participantId
= $this->participantCreate(array(
616 'event_id' => $this->_eventId
,
617 'contact_id' => $this->_contactId
,
620 $this->callAPISuccess('participant_payment', 'create', array(
621 'contribution_id' => $this->_contributionId
,
622 'participant_id' => $this->_participantId
,
625 $contribution = new CRM_Contribute_BAO_Contribution();
626 $contribution->id
= $this->_contributionId
;
627 $contribution->find();
628 $this->objects
['contribution'] = $contribution;
629 $this->input
= array(
630 'component' => 'event',
631 'total_amount' => 150.00,
632 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
633 'contactID' => $this->_contactId
,
634 'contributionID' => $contribution->id
,
635 'participantID' => $this->_participantId
,
638 $this->ids
['participant'] = $this->_participantId
;
639 $this->ids
['event'] = $this->_eventId
;
643 * Set up participant requirements for test.
645 public function _setUpPledgeObjects() {
646 $this->_pledgeId
= $this->pledgeCreate($this->_contactId
);
647 //we'll create membership payment here because to make setup more re-usable
648 $pledgePayment = $this->callAPISuccess('pledge_payment', 'create', array(
650 'pledge_id' => $this->_pledgeId
,
651 'contribution_id' => $this->_contributionId
,
653 'actual_amount' => 50,
656 $this->input
= array(
657 'component' => 'contribute',
658 'total_amount' => 150.00,
659 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
660 'contactID' => $this->_contactId
,
661 'contributionID' => $this->_contributionId
,
662 'pledgeID' => $this->_pledgeId
,
665 $this->ids
['pledge_payment'][] = $pledgePayment['id'];