From 2ee9bfaddc0cd73afe0d24b44382194c89115463 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 21 Jan 2020 10:16:39 +1300 Subject: [PATCH] Fix tests to use buildFeeFn --- CRM/Event/Form/Participant.php | 19 ++++++++++++++++--- .../CRM/Event/Form/ParticipantTest.php | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index b5fc3803e1..1a42efd40f 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -22,6 +22,20 @@ */ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment { + /** + * Participant ID - use getParticipantID. + * + * @var int + */ + public $_pId; + + /** + * ID of discount record. + * + * @var int + */ + public $_discountId; + public $useLivePageJS = TRUE; /** @@ -1669,7 +1683,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $form->addElement('hidden', 'hidden_feeblock', 1); } - $eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $form->_pId); + $eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $this->getParticipantID()); $form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, ['id' => 'hidden_eventFullMsg']); } @@ -1811,7 +1825,6 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment * * @return array * - * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ protected function preparePaidEventProcessing($params): array { @@ -2212,7 +2225,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment * @return int|null */ protected function getParticipantID() { - return $this->_id; + return $this->_id ?? $this->_pId; } } diff --git a/tests/phpunit/CRM/Event/Form/ParticipantTest.php b/tests/phpunit/CRM/Event/Form/ParticipantTest.php index ee02bff370..6fdf41e5aa 100644 --- a/tests/phpunit/CRM/Event/Form/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/Form/ParticipantTest.php @@ -316,8 +316,8 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { $form->_eventId = $event['id']; if (!empty($eventParams['is_monetary'])) { $form->_bltID = 5; - $form->_values['fee'] = []; $form->_isPaidEvent = TRUE; + $form->buildEventFeeForm($form); } return $form; } -- 2.25.1