Merge pull request #6340 from jitendrapurohit/CRM-16752
[civicrm-core.git] / tests / phpunit / CRM / Core / Payment / BaseIPNTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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
28
29 require_once 'CiviTest/CiviUnitTestCase.php';
30
31 /**
32 * Class CRM_Core_Payment_BaseIPNTest
33 */
34 class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase {
35
36 protected $_contributionTypeId;
37 protected $_contributionParams;
38 protected $_contactId;
39 protected $_contributionId;
40 protected $_participantId;
41 protected $_pledgeId;
42 protected $_eventId;
43 protected $_processorId;
44 protected $_contributionRecurParams;
45 protected $_paymentProcessor;
46 protected $IPN;
47 protected $_recurId;
48 protected $_membershipId;
49 protected $input;
50 protected $ids;
51 protected $objects;
52 public $DBResetRequired = FALSE;
53
54 public function setUp() {
55 parent::setUp();
56 $this->_processorId = $this->paymentProcessorAuthorizeNetCreate();
57 $this->input = $this->ids = $this->objects = array();
58 $this->IPN = new CRM_Core_Payment_AuthorizeNetIPN($this->input);
59
60 $this->_contactId = $this->individualCreate();
61 $this->ids['contact'] = $this->_contactId;
62 $this->_contributionTypeId = 1;
63
64 $this->_contributionParams = array(
65 'contact_id' => $this->_contactId,
66 'version' => 3,
67 'financial_type_id' => $this->_contributionTypeId,
68 'receive_date' => date('Ymd'),
69 'total_amount' => 150.00,
70 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885',
71 'currency' => 'USD',
72 'contribution_recur_id' => $this->_recurId,
73 'is_test' => 1,
74 'contribution_status_id' => 2,
75 );
76 $contribution = civicrm_api('contribution', 'create', $this->_contributionParams);
77 $this->assertAPISuccess($contribution, ' set-up of contribution ');
78 $this->_contributionId = $contribution['id'];
79
80 $contribution = new CRM_Contribute_BAO_Contribution();
81 $contribution->id = $this->_contributionId;
82 $contribution->find(TRUE);
83 $this->objects['contribution'] = $contribution;
84 }
85
86 public function tearDown() {
87 $this->quickCleanUpFinancialEntities();
88 CRM_Member_PseudoConstant::membershipType(NULL, TRUE);
89 CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'name', TRUE);
90 }
91
92 /**
93 * Test the LoadObjects function with recurring membership data.
94 */
95 public function testLoadMembershipObjects() {
96 $this->_setUpMembershipObjects();
97 $this->_setUpRecurringContribution();
98 $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
99 $this->assertFalse(empty($this->objects['membership']));
100 $this->assertArrayHasKey($this->_membershipTypeID, $this->objects['membership']);
101 $this->assertTrue(is_a($this->objects['membership'][$this->_membershipTypeID], 'CRM_Member_BAO_Membership'));
102 $this->assertTrue(is_a($this->objects['contributionType'], 'CRM_Financial_BAO_FinancialType'));
103 $this->assertFalse(empty($this->objects['contributionRecur']));
104 $this->assertFalse(empty($this->objects['paymentProcessor']));
105 }
106
107 /**
108 * Test the LoadObjects function with recurring membership data.
109 */
110 public function testLoadMembershipObjectsLoadAll() {
111 $this->_setUpMembershipObjects();
112 $this->_setUpRecurringContribution();
113 unset($this->ids['membership']);
114 $contribution = new CRM_Contribute_BAO_Contribution();
115 $contribution->id = $this->_contributionId;
116 $contribution->find(TRUE);
117 $contribution->loadRelatedObjects($this->input, $this->ids, FALSE, TRUE);
118 $this->assertFalse(empty($contribution->_relatedObjects['membership']));
119 $this->assertArrayHasKey($this->_membershipTypeID, $contribution->_relatedObjects['membership']);
120 $this->assertTrue(is_a($contribution->_relatedObjects['membership'][$this->_membershipTypeID], 'CRM_Member_BAO_Membership'));
121 $this->assertTrue(is_a($contribution->_relatedObjects['contributionType'], 'CRM_Financial_BAO_FinancialType'));
122 $this->assertFalse(empty($contribution->_relatedObjects['contributionRecur']));
123 $this->assertFalse(empty($contribution->_relatedObjects['paymentProcessor']));
124 }
125
126 /**
127 * Test the LoadObjects function with recurring membership data.
128 */
129 public function testsendMailMembershipObjects() {
130 $this->_setUpMembershipObjects();
131 $values = array();
132 $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
133 $msg = $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, TRUE);
134 $this->assertTrue(is_array($msg), "Message returned as an array in line");
135 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
136 $this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
137 $this->assertContains('Membership Type: General', $msg['body']);
138 }
139
140 /**
141 * Test the LoadObjects function with recurring membership data.
142 */
143 public function testsendMailMembershipWithoutLoadObjects() {
144 $this->_setUpMembershipObjects();
145 $values = array();
146 $msg = $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, TRUE);
147 $this->assertTrue(is_array($msg), "Message returned as an array in line" . __LINE__);
148 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
149 $this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
150 $this->assertContains('Membership Type: General', $msg['body']);
151 }
152
153 /**
154 * Test that loadObjects works with participant values.
155 */
156 public function testLoadParticipantObjects() {
157 $this->_setUpParticipantObjects();
158 $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
159 $this->assertFalse(empty($this->objects['participant']));
160 $this->assertTrue(is_a($this->objects['participant'], 'CRM_Event_BAO_Participant'));
161 $this->assertTrue(is_a($this->objects['contributionType'], 'CRM_Financial_BAO_FinancialType'));
162 $this->assertFalse(empty($this->objects['event']));
163 $this->assertTrue(is_a($this->objects['event'], 'CRM_Event_BAO_Event'));
164 $this->assertTrue(is_a($this->objects['contribution'], 'CRM_Contribute_BAO_Contribution'));
165 $this->assertFalse(empty($this->objects['event']->id));
166 }
167
168 /**
169 * Test the LoadObjects function with a participant.
170 */
171 public function testComposeMailParticipant() {
172 $this->_setUpParticipantObjects();
173 $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
174 $values = array();
175 $this->assertFalse(empty($this->objects['event']));
176 $msg = $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, TRUE);
177 $this->assertContains('registration has been received and your status has been updated to Attended.', $msg['body']);
178 $this->assertContains('Annual CiviCRM meet', $msg['html']);
179 }
180
181 /**
182 */
183 public function testComposeMailParticipantObjects() {
184 $this->_setUpParticipantObjects();
185 $values = array();
186 $msg = $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, TRUE);
187 $this->assertTrue(is_array($msg), "Message returned as an array in line" . __LINE__);
188 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
189 $this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
190 $this->assertContains('Thank you for your participation', $msg['body']);
191 }
192
193 /**
194 * Test the LoadObjects function with recurring membership data.
195 */
196 public function testsendMailParticipantObjectsCheckLog() {
197 $this->_setUpParticipantObjects();
198 $values = array();
199 require_once 'CiviTest/CiviMailUtils.php';
200 $mut = new CiviMailUtils($this, TRUE);
201 $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
202 $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, FALSE);
203 $mut->checkMailLog(array(
204 'Thank you for your participation',
205 'Annual CiviCRM meet',
206 'Mr. Anthony Anderson II',
207 )
208 );
209 $mut->stop();
210 }
211
212 /**
213 * Test the LoadObjects function with recurring membership data.
214 */
215 public function testsendMailParticipantObjectsNoMail() {
216 $this->_setUpParticipantObjects();
217 $event = new CRM_Event_BAO_Event();
218 $event->id = $this->_eventId;
219 $event->is_email_confirm = FALSE;
220 $event->save();
221 $values = array();
222 $tablesToTruncate = array(
223 'civicrm_mailing_spool',
224 );
225 $this->quickCleanup($tablesToTruncate, FALSE);
226 require_once 'CiviTest/CiviMailUtils.php';
227 $mut = new CiviMailUtils($this, TRUE);
228 $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
229 $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, FALSE);
230 $mut->assertMailLogEmpty('no mail should have been send as event set to no confirm');
231 $mut->stop();
232 }
233
234 /**
235 * Test that loadObjects works with participant values.
236 */
237 public function testLoadPledgeObjects() {
238 $this->_setUpPledgeObjects();
239 $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
240 $this->assertFalse(empty($this->objects['pledge_payment'][0]));
241 $this->assertTrue(is_a($this->objects['contributionType'], 'CRM_Financial_BAO_FinancialType'));
242 $this->assertTrue(is_a($this->objects['contribution'], 'CRM_Contribute_BAO_Contribution'));
243 $this->assertTrue(is_a($this->objects['pledge_payment'][0], 'CRM_Pledge_BAO_PledgePayment'));
244 $this->assertFalse(empty($this->objects['pledge_payment'][0]->id));
245 $this->assertEquals($this->_contributionTypeId, $this->objects['contributionType']->id);
246 $this->assertEquals($this->_processorId, $this->objects['paymentProcessor']['id']);
247 $this->assertEquals($this->_contributionId, $this->objects['contribution']->id);
248 $this->assertEquals($this->_contactId, $this->objects['contact']->id);
249 $this->assertEquals($this->_pledgeId, $this->objects['pledge_payment'][0]->pledge_id);
250 }
251
252 /**
253 * Test that loadObjects works with participant values.
254 */
255 public function testLoadPledgeObjectsInvalidPledgeID() {
256 $this->_setUpPledgeObjects();
257 $this->ids['pledge_payment'][0] = 0;
258 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
259 $this->assertArrayHasKey('error_message', $result);
260 $this->assertArrayNotHasKey('pledge_payment', $this->objects);
261 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
262 $this->ids['pledge_payment'][0] = NULL;
263 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
264 $this->assertArrayHasKey('error_message', $result);
265 $this->assertArrayNotHasKey('pledge_payment', $this->objects);
266 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
267 $this->ids['pledge_payment'][0] = '';
268 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
269 $this->assertArrayHasKey('error_message', $result);
270 $this->assertArrayNotHasKey('pledge_payment', $this->objects);
271 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
272
273 $this->ids['pledge_payment'][0] = 999;
274 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, $this->_processorId, array('return_error' => 1));
275 $this->assertArrayHasKey('error_message', $result);
276 $this->assertEquals('Could not find pledge payment record: 999', $result['error_message']);
277 }
278
279 /**
280 * Test the LoadObjects function with a pledge.
281 */
282 public function testsendMailPledge() {
283 $this->_setUpPledgeObjects();
284 $values = array();
285 $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, NULL);
286 $msg = $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, TRUE);
287 $this->assertContains('Contribution Information', $msg['html']);
288 }
289
290 /**
291 * Test that an error is returned if required set & no contribution page
292 */
293 public function testRequiredWithoutProcessorID() {
294 $this->_setUpPledgeObjects();
295 $values = array();
296 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
297 $this->assertArrayHasKey('error_message', $result);
298 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
299 // error is only returned if $required set to True
300 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, NULL, array('return_error' => 1));
301 $this->assertFalse(is_array($result));
302 //check that error is not returned if error checking not set
303 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('log_error' => 1));
304 $this->assertFalse(is_array($result));
305 }
306
307 /**
308 *
309 * Test that an error is not if required set & no processor ID
310 */
311 public function testRequiredWithContributionPage() {
312 $this->_setUpContributionObjects(TRUE);
313 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
314 $this->assertFalse(is_array($result), $result['error_message']);
315 }
316
317 /**
318 * Test that an error is returned if required set & contribution page exists
319 */
320 public function testRequiredWithContributionPageError() {
321 $this->_setUpContributionObjects();
322 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
323 $this->assertArrayHasKey('error_message', $result);
324 $this->assertEquals('Could not find contribution page for contribution record: 1', $result['error_message']);
325 // error is only returned if $required set to True
326 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, NULL, array('return_error' => 1));
327 $this->assertFalse(is_array($result));
328 //check that error is not returned if error checking not set
329 $result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('log_error' => 1));
330 $this->assertFalse(is_array($result));
331 }
332
333 /* @codingStandardsIgnoreStart
334 * Test calls main functions in sequence per 'main' - I had hoped to test the functions more
335 * fully but the calls to the POST happen in more than one function
336 * keeping this as good example of data to bring back to life later
337
338 public function testMainFunctionActions() {
339 $ids = $objects = array( );
340 $input['component'] = 'Contribute';
341 $postedParams = array(
342 'x_response_code' => 1,
343 'x_response_reason_code' => 1,
344 'x_response_reason_text' => 'This transaction has been approved.',
345 'x_avs_code' => 'Y',
346 'x_auth_code' => 140454,
347 'x_trans_id' => 4353599599,
348 'x_method' => 'CC',
349 'x_card_type' => 'American Express',
350 'x_account_number' => 'XXXX2701',
351 'x_first_name' => 'Arthur',
352 'x_last_name' => 'Jacobs',
353 'x_company' => null,
354 'x_address' => '866 2166th St SN',
355 'x_city' => 'Edwardstown',
356 'x_state' => 'WA',
357 'x_zip' => 98026,
358 'x_country' => 'US',
359 'x_phone' => null,
360 'x_fax' => null,
361 'x_email' => null,
362 'x_invoice_num' => 'a9fb56c24576lk4c9490f6',
363 'x_description' => 'my desc',
364 'x_type' => 'auth_capture',
365 'x_cust_id' => 5191,
366 'x_ship_to_first_name' => null,
367 'x_ship_to_last_name' => null,
368 'x_ship_to_company' => null,
369 'x_ship_to_address' => null,
370 'x_ship_to_city' => null,
371 'x_ship_to_state' => null,
372 'x_ship_to_zip' => null,
373 'x_ship_to_country' => null,
374 'x_amount' => 60.00,
375 'x_tax' => 0.00,
376 'x_duty' => 0.00,
377 'x_freight' => 0.00,
378 'x_tax_exempt' => FALSE,
379 'x_po_num' => null,
380 'x_MD5_Hash' => '069ECAD13C8E15AC205CDF92B8B58CC7',
381 'x_cvv2_resp_code' => null,
382 'x_cavv_response' => null,
383 'x_test_request' => false,
384 'description' => 'my description'
385 );
386 $this->IPN->getInput( $input, $ids );
387 $this->IPN->getIDs( $ids, $input );
388
389 CRM_Core_Error::debug_var( '$ids', $ids );
390 CRM_Core_Error::debug_var( '$input', $input );
391
392 $paymentProcessorID = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_PaymentProcessorType',
393 'AuthNet', 'id', 'name' );
394
395 if ( ! $this->IPN->validateData( $input, $ids, $objects, true, $paymentProcessorID ) ) {
396 return false;
397 }
398
399 if ( $component == 'contribute' && $ids['contributionRecur'] ) {
400 // check if first contribution is completed, else complete first contribution
401 $first = true;
402 if ( $objects['contribution']->contribution_status_id == 1 ) {
403 $first = false;
404 }
405 return $this->IPN->recur( $input, $ids, $objects, $first );
406 }
407 }
408 @codingStandardsIgnoreEnd */
409
410 /**
411 * Prepare for contribution Test - involving only contribution objects
412 *
413 * @param bool $contributionPage
414 */
415 public function _setUpContributionObjects($contributionPage = FALSE) {
416
417 $contribution = new CRM_Contribute_BAO_Contribution();
418 $contribution->id = $this->_contributionId;
419 $contribution->find(TRUE);
420 $contributionPageID = NULL;
421
422 if (!empty($contributionPage)) {
423 $dao = new CRM_Core_DAO();
424 $contribution_page = $dao->createTestObject('CRM_Contribute_DAO_ContributionPage');
425 $contribution_page->payment_processor = 1;
426 $contribution_page->save();
427 $contribution->contribution_page_id = $contributionPageID = $contribution_page->id;
428 //for unknown reasons trying to do a find & save on a contribution with a receive_date set
429 // doesn't work. This seems of minimal relevance to this test so ignoring
430 // note that in tests it worked sometimes & not others - dependent on which other tests run.
431 // running all CRM_Core tests caused failure as did just the single failing test. But running
432 // just this class succeeds - because it actually doesn't do a mysql update on the following save
433 // (unknown reason)
434 unset($contribution->receive_date);
435 $contribution->save();
436 }
437
438 $this->objects['contribution'] = $contribution;
439 $this->input = array(
440 'component' => 'contribute',
441 'contribution_page_id' => $contributionPageID,
442 'total_amount' => 110.00,
443 'invoiceID' => "c8acb91e080ad7777a2adc119c192885",
444 'contactID' => $this->_contactId,
445 'contributionID' => $this->objects['contribution']->id,
446 );
447 }
448
449 /**
450 * Prepare for membership test.
451 */
452 public function _setUpMembershipObjects() {
453 try {
454 $this->_membershipTypeID = $this->membershipTypeCreate();
455 $this->_membershipStatusID = $this->membershipStatusCreate('test status');
456 }
457 catch (Exception$e) {
458 echo $e->getMessage();
459 }
460 CRM_Member_PseudoConstant::membershipType($this->_membershipTypeID, TRUE);
461 CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'name', TRUE);
462 $this->_membershipParams = array(
463 'contact_id' => $this->_contactId,
464 'membership_type_id' => $this->_membershipTypeID,
465 'join_date' => '2009-01-21',
466 'start_date' => '2009-01-21',
467 'end_date' => '2009-12-21',
468 'source' => 'Payment',
469 'is_override' => 1,
470 'status_id' => $this->_membershipStatusID,
471 'version' => 3,
472 );
473
474 $membership = $this->callAPISuccess('membership', 'create', $this->_membershipParams);
475
476 $this->_membershipId = $membership['id'];
477 //we'll create membership payment here because to make setup more re-usable
478 civicrm_api('membership_payment', 'create', array(
479 'version' => 3,
480 'contribution_id' => $this->_contributionId,
481 'membership_id' => $this->_membershipId,
482 ));
483
484 $this->input = array(
485 'component' => 'contribute',
486 'total_amount' => 150.00,
487 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
488 'contactID' => $this->_contactId,
489 'contributionID' => $this->objects['contribution']->id,
490 'membershipID' => $this->_membershipId,
491 );
492
493 $this->ids['membership'] = $this->_membershipId;
494 }
495
496 public function _setUpRecurringContribution() {
497 $this->_contributionRecurParams = array(
498 'contact_id' => $this->_contactId,
499 'amount' => 150.00,
500 'currency' => 'USD',
501 'frequency_unit' => 'week',
502 'frequency_interval' => 1,
503 'installments' => 2,
504 'start_date' => date('Ymd'),
505 'create_date' => date('Ymd'),
506 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885',
507 'contribution_status_id' => 2,
508 'is_test' => 1,
509 'financial_type_id' => $this->_contributionTypeId,
510 'version' => 3,
511 'payment_processor_id' => $this->_processorId,
512 );
513 $this->_recurId = civicrm_api('contribution_recur', 'create', $this->_contributionRecurParams);
514 $this->assertAPISuccess($this->_recurId, 'line ' . __LINE__ . ' set-up of recurring contrib');
515 $this->_recurId = $this->_recurId['id'];
516 $this->input['contributionRecurId'] = $this->_recurId;
517 $this->ids['contributionRecur'] = $this->_recurId;
518 }
519
520 /**
521 * Set up participant requirements for test.
522 */
523 public function _setUpParticipantObjects() {
524 $event = $this->eventCreate(array('is_email_confirm' => 1));
525 $this->assertAPISuccess($event, 'line ' . __LINE__ . ' set-up of event');
526 $this->_eventId = $event['id'];
527 $this->_participantId = $this->participantCreate(array(
528 'event_id' => $this->_eventId,
529 'contact_id' => $this->_contactId,
530 ));
531 //we'll create membership payment here because to make setup more re-usable
532 $participantPayment = civicrm_api('participant_payment', 'create', array(
533 'version' => 3,
534 'contribution_id' => $this->_contributionId,
535 'participant_id' => $this->_participantId,
536 ));
537 $this->assertAPISuccess($participantPayment, 'line ' . __LINE__ . ' set-up of event');
538 $contribution = new CRM_Contribute_BAO_Contribution();
539 $contribution->id = $this->_contributionId;
540 $contribution->find();
541 $this->objects['contribution'] = $contribution;
542 $this->input = array(
543 'component' => 'event',
544 'total_amount' => 150.00,
545 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
546 'contactID' => $this->_contactId,
547 'contributionID' => $contribution->id,
548 'participantID' => $this->_participantId,
549 );
550
551 $this->ids['participant'] = $this->_participantId;
552 $this->ids['event'] = $this->_eventId;
553 }
554
555 /**
556 * Set up participant requirements for test.
557 */
558 public function _setUpPledgeObjects() {
559 $this->_pledgeId = $this->pledgeCreate($this->_contactId);
560 //we'll create membership payment here because to make setup more re-usable
561 $pledgePayment = civicrm_api('pledge_payment', 'create', array(
562 'version' => 3,
563 'pledge_id' => $this->_pledgeId,
564 'contribution_id' => $this->_contributionId,
565 'status_id' => 1,
566 'actual_amount' => 50,
567 ));
568 $this->assertAPISuccess($pledgePayment, 'line ' . __LINE__ . ' set-up of pledge payment');
569 $this->input = array(
570 'component' => 'contribute',
571 'total_amount' => 150.00,
572 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
573 'contactID' => $this->_contactId,
574 'contributionID' => $this->_contributionId,
575 'pledgeID' => $this->_pledgeId,
576 );
577
578 $this->ids['pledge_payment'][] = $pledgePayment['id'];
579 }
580
581 }