From 9cc488976e2a4394c94f898e86188cf3a2b3d74a Mon Sep 17 00:00:00 2001 From: Sandor Semsey Date: Thu, 23 Feb 2023 13:48:08 +0100 Subject: [PATCH] pass participant contact_id as target_contact_id when creating event registration activity --- CRM/Event/BAO/Participant.php | 2 +- tests/phpunit/CRM/Event/BAO/ParticipantTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index e67401c82a..97869fe7f8 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -181,7 +181,7 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant implements \Ci ) { // Default status if not specified $participant->status_id = $participant->status_id ?: self::fields()['participant_status_id']['default']; - CRM_Activity_BAO_Activity::addActivity($participant, 'Event Registration'); + CRM_Activity_BAO_Activity::addActivity($participant, 'Event Registration', $participant->contact_id); } //CRM-5403 diff --git a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php index 89f787d373..ff514a119e 100644 --- a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php @@ -279,6 +279,9 @@ class CRM_Event_BAO_ParticipantTest extends CiviUnitTestCase { $this->assertDBCompareValue('CRM_Activity_DAO_Activity', $this->_contactId, 'source_record_id', 'source_contact_id', $participant->id, 'Check DB for activity added for the participant' ); + //Checking for participant contact_id added to activity target. + $params_activity = ['contact_id' => $this->_contactId, 'record_type_id' => 3]; + $this->assertDBCompareValues('CRM_Activity_DAO_ActivityContact', $params_activity, $params_activity); $params = array_merge($params, [ 'id' => $participant->id, @@ -303,6 +306,9 @@ class CRM_Event_BAO_ParticipantTest extends CiviUnitTestCase { $this->assertDBCompareValue('CRM_Activity_DAO_Activity', $this->_contactId, 'source_record_id', 'source_contact_id', $participant->id, 'Check DB for activity added for the participant' ); + //Checking for participant contact_id added to activity target. + $params_activity = ['contact_id' => $this->_contactId, 'record_type_id' => 3]; + $this->assertDBCompareValues('CRM_Activity_DAO_ActivityContact', $params_activity, $params_activity); //Checking for Note added in the table for relative participant. $session = CRM_Core_Session::singleton(); -- 2.25.1