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 * Test class for Batch API - civicrm_participant_*
31 * @package CiviCRM_APIv3
35 * Class api_v3_ParticipantTest
38 class api_v3_ParticipantTest
extends CiviUnitTestCase
{
40 protected $_apiversion;
42 protected $_contactID;
43 protected $_contactID2;
44 protected $_createdParticipants;
45 protected $_participantID;
47 protected $_individualId;
50 public function setUp() {
51 $this->_apiversion
= 3;
53 $this->_entity
= 'participant';
54 $event = $this->eventCreate(NULL);
55 $this->_eventID
= $event['id'];
57 $this->_contactID
= $this->individualCreate();
59 $this->_createdParticipants
= [];
60 $this->_individualId
= $this->individualCreate();
62 $this->_participantID
= $this->participantCreate([
63 'contact_id' => $this->_contactID
,
64 'event_id' => $this->_eventID
,
66 $this->_contactID2
= $this->individualCreate();
67 $this->_participantID2
= $this->participantCreate([
68 'contact_id' => $this->_contactID2
,
69 'event_id' => $this->_eventID
,
70 'registered_by_id' => $this->_participantID
,
72 $this->_participantID3
= $this->participantCreate([
73 'contact_id' => $this->_contactID2
,
74 'event_id' => $this->_eventID
,
77 'contact_id' => $this->_contactID
,
78 'event_id' => $this->_eventID
,
81 // to ensure it matches later on
82 'register_date' => '2007-07-21 00:00:00',
83 'source' => 'Online Event Registration: API Testing',
87 public function tearDown() {
88 $this->eventDelete($this->_eventID
);
90 'civicrm_custom_group',
91 'civicrm_custom_field',
93 'civicrm_participant',
95 // true tells quickCleanup to drop any tables that might have been created in the test
96 $this->quickCleanup($tablesToTruncate, TRUE);
100 * Check that getCount can count past 25.
102 public function testGetCountLimit() {
105 for ($count = $this->callAPISuccessGetCount('Participant', []); $count < 27; $count++
) {
106 $contactIDs[] = $contactID = $this->individualCreate();
107 $this->participantCreate(['contact_id' => $contactID, 'event_id' => $this->_eventID
]);
109 $this->callAPISuccessGetCount('Participant', [], 27);
111 foreach ($contactIDs as $contactID) {
112 $this->callAPISuccess('Contact', 'delete', ['id' => $contactID]);
117 * Test get participants with role_id.
119 public function testGetParticipantWithRole() {
121 foreach ($roleId as $role) {
122 $this->participantCreate([
123 'contact_id' => $this->individualCreate(),
125 'event_id' => $this->_eventID
,
132 $result = $this->callAPISuccess('participant', 'get', $params);
133 //Assert all the returned participants has a role_id of 2
134 foreach ($result['values'] as $pid => $values) {
135 $this->assertEquals($values['participant_role_id'], 2);
138 $this->participantCreate([
139 'id' => $this->_participantID
,
141 'event_id' => $this->_eventID
,
144 $params['role_id'] = [
147 $result = $this->callAPISuccess('participant', 'get', $params);
148 foreach ($result['values'] as $pid => $values) {
149 $this->assertEquals($values['participant_role_id'], NULL);
155 * Check with complete array + custom field
156 * Note that the test is written on purpose without any
157 * variables specific to participant so it can be replicated into other entities
158 * and / or moved to the automated test suite
160 public function testCreateWithCustom() {
161 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__
, __FILE__
);
163 $params = $this->_params
;
164 $params['custom_' . $ids['custom_field_id']] = "custom string";
166 $result = $this->callAPIAndDocument($this->_entity
, 'create', $params, __FUNCTION__
, __FILE__
);
168 $this->assertEquals($result['id'], $result['values'][$result['id']]['id']);
170 $check = $this->callAPISuccess($this->_entity
, 'get', ['id' => $result['id']]);
171 $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__
);
173 $this->customFieldDelete($ids['custom_field_id']);
174 $this->customGroupDelete($ids['custom_group_id']);
178 * Check with participant_id.
180 public function testGetParticipantIdOnly() {
182 'participant_id' => $this->_participantID
,
186 'participant_register_date',
187 'participant_source',
190 $result = $this->callAPISuccess('participant', 'get', $params);
191 $this->assertAPISuccess($result, " in line " . __LINE__
);
192 $this->assertEquals($result['values'][$this->_participantID
]['event_id'], $this->_eventID
);
193 $this->assertEquals($result['values'][$this->_participantID
]['participant_register_date'], '2007-02-19 00:00:00');
194 $this->assertEquals($result['values'][$this->_participantID
]['participant_source'], 'Wimbeldon');
196 'id' => $this->_participantID
,
197 'return' => 'id,participant_register_date,event_id',
200 $result = $this->callAPISuccess('participant', 'get', $params);
201 $this->assertEquals($result['values'][$this->_participantID
]['event_id'], $this->_eventID
);
202 $this->assertEquals($result['values'][$this->_participantID
]['participant_register_date'], '2007-02-19 00:00:00');
207 * Test permission for participant get.
209 public function testGetParticipantWithPermission() {
210 $config = CRM_Core_Config
::singleton();
211 $config->userPermissionClass
->permissions
= [];
213 'event_id' => $this->_eventID
,
214 'check_permissions' => TRUE,
218 'participant_register_date',
219 'participant_source',
222 $this->callAPIFailure('participant', 'get', $params);
224 $params['check_permissions'] = FALSE;
225 $result = $this->callAPISuccess('participant', 'get', $params);
226 $this->assertEquals($result['is_error'], 0);
230 * Check with params id.
232 public function testGetParamsAsIdOnly() {
234 'id' => $this->_participantID
,
236 $result = $this->callAPIAndDocument('participant', 'get', $params, __FUNCTION__
, __FILE__
);
237 $this->assertEquals($result['values'][$this->_participantID
]['event_id'], $this->_eventID
);
238 $this->assertEquals($result['values'][$this->_participantID
]['participant_register_date'], '2007-02-19 00:00:00');
239 $this->assertEquals($result['values'][$this->_participantID
]['participant_source'], 'Wimbeldon');
240 $this->assertEquals($result['id'], $result['values'][$this->_participantID
]['id']);
244 * Check with params id.
246 public function testGetNestedEventGet() {
247 //create a second event & add participant to it.
248 $event = $this->eventCreate(NULL);
249 $this->callAPISuccess('participant', 'create', [
250 'event_id' => $event['id'],
251 'contact_id' => $this->_contactID
,
254 $description = "Demonstrates use of nested get to fetch event data with participant records.";
255 $subfile = "NestedEventGet";
257 'id' => $this->_participantID
,
258 'api.event.get' => 1,
260 $result = $this->callAPIAndDocument('participant', 'get', $params, __FUNCTION__
, __FILE__
, $description, $subfile);
261 $this->assertEquals($result['values'][$this->_participantID
]['event_id'], $this->_eventID
);
262 $this->assertEquals($result['values'][$this->_participantID
]['participant_register_date'], '2007-02-19 00:00:00');
263 $this->assertEquals($result['values'][$this->_participantID
]['participant_source'], 'Wimbeldon');
264 $this->assertEquals($this->_eventID
, $result['values'][$this->_participantID
]['api.event.get']['id']);
268 * Check Participant Get respects return properties.
270 public function testGetWithReturnProperties() {
272 'contact_id' => $this->_contactID
,
273 'return.status_id' => 1,
274 'return.participant_status_id' => 1,
275 'options' => ['limit' => 1],
277 $result = $this->callAPISuccess('participant', 'get', $params);
278 $this->assertArrayHasKey('participant_status_id', $result['values'][$result['id']]);
282 * Check with contact_id.
284 public function testGetContactIdOnly() {
286 'contact_id' => $this->_contactID
,
288 $participant = $this->callAPISuccess('participant', 'get', $params);
290 $this->assertEquals($this->_participantID
, $participant['id']);
291 $this->assertEquals($this->_eventID
, $participant['values'][$participant['id']]['event_id']);
292 $this->assertEquals('2007-02-19 00:00:00', $participant['values'][$participant['id']]['participant_register_date']);
293 $this->assertEquals('Wimbeldon', $participant['values'][$participant['id']]['participant_source']);
294 $this->assertEquals($participant['id'], $participant['values'][$participant['id']]['id']);
298 * Check with event_id.
301 public function testGetMultiMatchReturnFirst() {
303 'event_id' => $this->_eventID
,
307 $participant = $this->callAPISuccess('participant', 'get', $params);
308 $this->assertNotNull($participant['id']);
312 * Check with event_id.
313 * in v3 this should return all participants
315 public function testGetMultiMatchNoReturnFirst() {
317 'event_id' => $this->_eventID
,
319 $participant = $this->callAPISuccess('participant', 'get', $params);
320 $this->assertNotNull($participant['count'], 3);
323 ///////////////// civicrm_participant_get methods
326 * Test civicrm_participant_get with empty params.
327 * In this case all the participant records are returned.
329 public function testSearchEmptyParams() {
330 $result = $this->callAPISuccess('participant', 'get', []);
331 // expecting 3 participant records
332 $this->assertEquals($result['count'], 3);
336 * Check with participant_id.
338 public function testSearchParticipantIdOnly() {
340 'participant_id' => $this->_participantID
,
342 $participant = $this->callAPISuccess('participant', 'get', $params);
343 $this->assertEquals($participant['values'][$this->_participantID
]['event_id'], $this->_eventID
);
344 $this->assertEquals($participant['values'][$this->_participantID
]['participant_register_date'], '2007-02-19 00:00:00');
345 $this->assertEquals($participant['values'][$this->_participantID
]['participant_source'], 'Wimbeldon');
349 * Check with contact_id.
351 public function testSearchContactIdOnly() {
352 // Should get 2 participant records for this contact.
354 'contact_id' => $this->_contactID2
,
356 $participant = $this->callAPISuccess('participant', 'get', $params);
358 $this->assertEquals($participant['count'], 2);
362 * Check with event_id.
364 public function testSearchByEvent() {
365 // Should get >= 3 participant records for this event. Also testing that last_name and event_title are returned.
367 'event_id' => $this->_eventID
,
368 'return.last_name' => 1,
369 'return.event_title' => 1,
371 $participant = $this->callAPISuccess('participant', 'get', $params);
372 if ($participant['count'] < 3) {
373 $this->fail("Event search returned less than expected miniumum of 3 records.");
376 $this->assertEquals($participant['values'][$this->_participantID
]['last_name'], 'Anderson');
377 $this->assertEquals($participant['values'][$this->_participantID
]['event_title'], 'Annual CiviCRM meet');
381 * Check with event_id.
384 public function testSearchByEventWithLimit() {
385 // Should 2 participant records since we're passing rowCount = 2.
387 'event_id' => $this->_eventID
,
390 $participant = $this->callAPISuccess('participant', 'get', $params);
392 $this->assertEquals($participant['count'], 2);
396 * Test search by lead booker (registered by ID)
398 public function testSearchByRegisteredById() {
400 'registered_by_id' => $this->_participantID
,
402 $participant = $this->callAPISuccess('participant', 'get', $params);
404 $this->assertEquals($participant['count'], 1);
405 $this->assertEquals($participant['id'], $this->_participantID2
);
408 ///////////////// civicrm_participant_create methods
411 * Test civicrm_participant_create with empty params.
413 public function testCreateEmptyParams() {
415 $result = $this->callAPIFailure('participant', 'create', $params);
419 * Check with event_id.
421 public function testCreateMissingContactID() {
422 $this->callAPIFailure('participant', 'create', ['event_id' => $this->_eventID
]);
426 * Check with contact_id.
429 public function testCreateMissingEventID() {
430 $this->callAPIFailure('participant', 'create', ['contact_id' => $this->_contactID
]);
434 * Check with contact_id & event_id
436 public function testCreateEventIdOnly() {
438 'contact_id' => $this->_contactID
,
439 'event_id' => $this->_eventID
,
441 $participant = $this->callAPISuccess('participant', 'create', $params);
442 $this->getAndCheck($params, $participant['id'], 'participant');
446 * Check with complete array.
448 public function testCreateAllParams() {
449 $participant = $this->callAPISuccess('participant', 'create', $this->_params
);
450 $this->_participantID
= $participant['id'];
451 $this->assertDBState('CRM_Event_DAO_Participant', $participant['id'], $this->_params
);
455 * Test that an overlong source is handled.
457 public function testLongSource() {
458 $params = array_merge($this->_params
, [
459 'source' => 'a string that is even longer than the 128 character limit that is allowed for this field because sometimes you want, you know, an essay',
461 $baoCreated = CRM_Event_BAO_Participant
::create($params);
462 $this->assertEquals('a string that is even longer than the 128 character limit that is allowed for this field because sometimes you want, you know...', $baoCreated->source
);
463 // @todo - currently the api will still reject the long string.
464 //$this->callAPISuccess('participant', 'create', $params);
468 * Test to check if receive date is being changed per CRM-9763
470 public function testCreateUpdateReceiveDate() {
471 $participant = $this->callAPISuccess('participant', 'create', $this->_params
);
473 'id' => $participant['id'],
476 $this->callAPISuccess('participant', 'create', $update);
477 $this->getAndCheck(array_merge($this->_params
, $update), $participant['id'], 'participant');
481 * Test to check if participant fee level is being changed per CRM-9781
483 public function testCreateUpdateParticipantFeeLevel() {
484 $myParams = $this->_params +
['participant_fee_level' => CRM_Core_DAO
::VALUE_SEPARATOR
. "fee" . CRM_Core_DAO
::VALUE_SEPARATOR
];
485 $participant = $this->callAPISuccess('participant', 'create', $myParams);
487 'id' => $participant['id'],
490 $update = $this->callAPISuccess('participant', 'create', $update);
492 $this->assertEquals($participant['values'][$participant['id']]['fee_level'],
493 $update['values'][$participant['id']]['fee_level']
496 $this->callAPISuccess('participant', 'delete', ['id' => $participant['id']]);
500 * Test the line items for participant fee with multiple price field values.
502 public function testCreateParticipantLineItems() {
503 // Create a price set for this event.
505 $priceset = $this->callAPISuccess('PriceSet', 'create', [
506 'name' => 'my_price_set',
507 'title' => 'My Price Set',
510 'financial_type_id' => 4,
511 // 'entity' => array('civicrm_event' => array($this->_eventID)),
514 // Add the price set to the event with another API call.
515 // I tried to do this at once, but it did not work.
517 $priceset = $this->callAPISuccess('PriceSet', 'create', [
518 'entity_table' => 'civicrm_event',
519 'entity_id' => $this->_eventID
,
520 'id' => $priceset['id'],
523 $pricefield = $this->callAPISuccess('PriceField', 'create', [
524 'price_set_id' => $priceset['id'],
525 'name' => 'mypricefield',
526 'label' => 'My Price Field',
527 'html_type' => 'Text',
529 'is_display_amounts' => 1,
533 $pfv1 = $this->callAPISuccess('PriceFieldValue', 'create', [
534 'price_field_id' => $pricefield['id'],
535 'name' => 'pricefieldvalue1',
536 'label' => 'pricefieldvalue1',
539 'financial_type_id' => 4,
542 $pfv2 = $this->callAPISuccess('PriceFieldValue', 'create', [
543 'price_field_id' => $pricefield['id'],
544 'name' => 'pricefieldvalue2',
545 'label' => 'pricefieldvalue2',
548 'financial_type_id' => 4,
551 // pay 2 times price field value 1, and 2 times price field value 2.
552 $myParams = $this->_params +
['participant_fee_level' => CRM_Core_DAO
::VALUE_SEPARATOR
. "pricefieldvalue1 - 2" . CRM_Core_DAO
::VALUE_SEPARATOR
. "pricefieldvalue2 - 2" . CRM_Core_DAO
::VALUE_SEPARATOR
];
553 $participant = $this->callAPISuccess('participant', 'create', $myParams);
555 // expect 2 line items.
556 $lineItems = $this->callAPISuccess('LineItem', 'get', [
557 'entity_id' => $participant['id'],
558 'entity_table' => 'civicrm_participant',
561 $this->assertEquals(2, $lineItems['count']);
563 // Check quantity, label and unit price of lines.
564 // TODO: These assertions depend on the order of the line items, which is
565 // technically incorrect.
567 $lineItem = array_pop($lineItems['values']);
568 $this->assertEquals(2, $lineItem['qty']);
569 $this->assertEquals(5, $lineItem['unit_price']);
570 $this->assertEquals('pricefieldvalue2', $lineItem['label']);
572 $lineItem = array_pop($lineItems['values']);
573 $this->assertEquals(2, $lineItem['qty']);
574 $this->assertEquals(20, $lineItem['unit_price']);
575 $this->assertEquals('pricefieldvalue1', $lineItem['label']);
578 $this->callAPISuccess('participant', 'delete', ['id' => $participant['id']]);
580 // TODO: I think the price set should be removed, but I don't know how
581 // to decouple it properly from the event. For the moment, I'll just comment
582 // out the lines below.
585 $this->callAPISuccess('PriceFieldValue', 'delete', array('id' => $pfv1['id']));
586 $this->callAPISuccess('PriceFieldValue', 'delete', array('id' => $pfv2['id']));
587 $this->callAPISuccess('PriceField', 'delete', array('id' => $pricefield['id']));
588 $this->callAPISuccess('PriceSet', 'delete', array('id' => $priceset['id']));
593 * Check with complete array.
595 public function testUpdate() {
596 $participantId = $this->participantCreate([
597 'contactID' => $this->_individualId
,
598 'eventID' => $this->_eventID
,
601 'id' => $participantId,
602 'contact_id' => $this->_individualId
,
603 'event_id' => $this->_eventID
,
606 'register_date' => '2006-01-21',
607 'source' => 'US Open',
609 $participant = $this->callAPISuccess('participant', 'create', $params);
610 $this->getAndCheck($params, $participant['id'], 'participant');
611 $result = $this->participantDelete($params['id']);
615 * Test to check if participant fee level is being changed per CRM-9781
616 * Try again without a custom separater to check that one isn't added
617 * (get & check won't accept an array)
619 public function testUpdateCreateParticipantFeeLevelNoSeparator() {
621 $myParams = $this->_params +
['participant_fee_level' => "fee"];
622 $participant = $this->callAPISuccess('participant', 'create', $myParams);
623 $this->assertAPISuccess($participant);
625 'id' => $participant['id'],
628 $this->callAPISuccess('participant', 'create', $update);
629 $this->assertEquals($participant['values'][$participant['id']]['fee_level'],
630 $myParams['participant_fee_level']
632 $this->getAndCheck($update, $participant['id'], 'participant');
635 ///////////////// civicrm_participant_update methods
638 * Test civicrm_participant_update with wrong params type.
640 public function testUpdateWrongParamsType() {
641 $params = 'a string';
642 $result = $this->callAPIFailure('participant', 'create', $params);
643 $this->assertEquals('Input variable `params` is not an array', $result['error_message']);
647 * Check with empty array.
649 public function testUpdateEmptyParams() {
651 $participant = $this->callAPIFailure('participant', 'create', $params);
652 $this->assertEquals($participant['error_message'], 'Mandatory key(s) missing from params array: event_id, contact_id');
656 * Check without event_id.
658 public function testUpdateWithoutEventId() {
659 $participantId = $this->participantCreate(['contactID' => $this->_individualId
, 'eventID' => $this->_eventID
]);
661 'contact_id' => $this->_individualId
,
664 'register_date' => '2006-01-21',
665 'source' => 'US Open',
666 'event_level' => 'Donation',
668 $participant = $this->callAPIFailure('participant', 'create', $params);
669 $this->assertEquals($participant['error_message'], 'Mandatory key(s) missing from params array: event_id');
670 // Cleanup created participant records.
671 $result = $this->participantDelete($participantId);
675 * Check with Invalid participantId.
677 public function testUpdateWithWrongParticipantId() {
682 'register_date' => '2006-01-21',
683 'source' => 'US Open',
684 'event_level' => 'Donation',
686 $participant = $this->callAPIFailure('Participant', 'update', $params);
690 * Check with Invalid ContactId.
692 public function testUpdateWithWrongContactId() {
693 $participantId = $this->participantCreate([
694 'contactID' => $this->_individualId
,
695 'eventID' => $this->_eventID
,
696 ], $this->_apiversion
);
698 'id' => $participantId,
699 'contact_id' => 12345,
702 'register_date' => '2006-01-21',
703 'source' => 'US Open',
704 'event_level' => 'Donation',
706 $participant = $this->callAPIFailure('participant', 'create', $params);
707 $result = $this->participantDelete($participantId);
710 ///////////////// civicrm_participant_delete methods
713 * Test civicrm_participant_delete with wrong params type.
715 public function testDeleteWrongParamsType() {
716 $params = 'a string';
717 $result = $this->callAPIFailure('participant', 'delete', $params);
721 * Test civicrm_participant_delete with empty params.
723 public function testDeleteEmptyParams() {
725 $result = $this->callAPIFailure('participant', 'delete', $params);
729 * Check with participant_id.
731 public function testParticipantDelete() {
733 'id' => $this->_participantID
,
735 $participant = $this->callAPISuccess('participant', 'delete', $params);
736 $this->assertAPISuccess($participant);
737 $this->assertDBState('CRM_Event_DAO_Participant', $this->_participantID
, NULL, TRUE);
741 * Check without participant_id.
743 * This should return an error because required param is missing..
745 public function testParticipantDeleteMissingID() {
747 'event_id' => $this->_eventID
,
749 $participant = $this->callAPIFailure('participant', 'delete', $params);
750 $this->assertNotNull($participant['error_message']);
754 * Delete with a get - a 'criteria delete'
756 public function testNestedDelete() {
757 $description = "Criteria delete by nesting a GET & a DELETE.";
758 $subfile = "NestedDelete";
759 $participants = $this->callAPISuccess('Participant', 'Get', []);
760 $this->assertEquals($participants['count'], 3);
761 $params = ['contact_id' => $this->_contactID2
, 'api.participant.delete' => 1];
762 $this->callAPIAndDocument('Participant', 'Get', $params, __FUNCTION__
, __FILE__
, $description, $subfile);
763 $check = $this->callAPISuccess('participant', 'getcount', []);
764 $this->assertEquals(1, $check, "only one participant should be left");
768 * Test creation of a participant with an associated contribution.
770 public function testCreateParticipantWithPayment() {
771 $description = "Single function to create contact with partipation & contribution.
772 Note that in the case of 'contribution' the 'create' is implied (api.contribution.create)";
773 $subfile = "CreateParticipantPayment";
775 'contact_type' => 'Individual',
776 'display_name' => 'dlobo',
777 'api.participant' => [
778 'event_id' => $this->_eventID
,
781 'format.only_id' => 1,
783 'api.contribution.create' => [
784 'financial_type_id' => 1,
785 'total_amount' => 100,
786 'format.only_id' => 1,
788 'api.participant_payment.create' => [
789 'contribution_id' => '$value.api.contribution.create',
790 'participant_id' => '$value.api.participant',
794 $result = $this->callAPIAndDocument('contact', 'create', $params, __FUNCTION__
, __FILE__
, $description, $subfile);
795 $this->assertEquals(1, $result['values'][$result['id']]['api.participant_payment.create']['count']);
796 $this->callAPISuccess('contact', 'delete', ['id' => $result['id']]);
800 * Test participant invoke post hook after status update.
802 public function testPostHookForAdditionalParticipant() {
803 $participantID = $this->participantCreate([
804 'contact_id' => $this->_contactID
,
806 'event_id' => $this->_eventID
,
808 $participantID2 = $this->participantCreate([
809 'contact_id' => $this->_contactID2
,
810 'event_id' => $this->_eventID
,
812 'registered_by_id' => $participantID,
815 $this->hookClass
->setHook('civicrm_post', [$this, 'onPost']);
817 'id' => $participantID,
820 $this->callAPISuccess('Participant', 'create', $params);
822 $result = $this->callAPISuccess('Participant', 'get', ['source' => 'Post Hook Update']);
823 $this->assertEquals(2, $result['count']);
825 $expected = [$participantID, $participantID2];
826 $actual = array_keys($result['values']);
827 $this->checkArrayEquals($expected, $actual);