From 097f58401ec8c1ce29840c3b0ba636c68453785c Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Mon, 11 Apr 2022 14:31:32 -0400 Subject: [PATCH] Event self-service cancel: allow cancelling Waitlist registration --- CRM/Event/BAO/Participant.php | 4 ++-- tests/phpunit/CRM/Event/BAO/ParticipantTest.php | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index ec9a4eb7af..0cb57b9989 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1866,8 +1866,8 @@ WHERE civicrm_participant.contact_id = {$contactID} AND $details['ineligible_message'] = ts('This event registration can not be transferred or cancelled. Contact the event organizer if you have questions.'); return $details; } - //verify participant status is still Registered - if ($details['status'] != 'Registered') { + // Verify participant status is one that can be self-cancelled + if (!in_array($details['status'], ['Registered', 'Pending from pay later', 'On waitlist'])) { $details['eligible'] = FALSE; $details['ineligible_message'] = "You cannot transfer or cancel your registration for " . $eventTitle . ' as you are not currently registered for this event.'; return $details; diff --git a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php index c08340b0d4..b05c01f2af 100644 --- a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php @@ -454,6 +454,15 @@ class CRM_Event_BAO_ParticipantTest extends CiviUnitTestCase { 'isBackOffice' => FALSE, 'successExpected' => TRUE, ]; + // Allow to cancel if on waitlist + $scenarios[] = [ + 'selfSvcEnabled' => 1, + 'selfSvcHours' => 12, + 'hoursToEvent' => 16, + 'participantStatusId' => 7, + 'isBackOffice' => FALSE, + 'successExpected' => TRUE, + ]; // Too late to self-service $scenarios[] = [ 'selfSvcEnabled' => 1, @@ -463,7 +472,7 @@ class CRM_Event_BAO_ParticipantTest extends CiviUnitTestCase { 'isBackOffice' => FALSE, 'successExpected' => FALSE, ]; - // Participant status is other than "Registered". + // Participant status cannot cancel (ex: Attended) $scenarios[] = [ 'selfSvcEnabled' => 1, 'selfSvcHours' => 12, -- 2.25.1