From 0aa23695ba765e5cdc82dd13431cc091f8fd3500 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 6 Jun 2023 10:32:20 +1200 Subject: [PATCH] Use same key as new function for easier transition --- .../CRM/Contribute/BAO/ContributionTest.php | 2 +- .../CRM/Event/Form/ParticipantTest.php | 43 +++++++++---------- .../Event/Form/Registration/ConfirmTest.php | 2 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 +- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index d973ad5141..d6c8eb28ea 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -616,7 +616,7 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; $this->_contactId = $this->individualCreate(); $event = $this->legacyEventCreatePaid([]); $this->_eventId = $event['id']; - $priceSetID = $this->ids['PriceSet']['event']; + $priceSetID = $this->ids['PriceSet']['PaidEvent']; $paramsField = [ 'label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), diff --git a/tests/phpunit/CRM/Event/Form/ParticipantTest.php b/tests/phpunit/CRM/Event/Form/ParticipantTest.php index 6cd0a03954..169294cc40 100644 --- a/tests/phpunit/CRM/Event/Form/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/Form/ParticipantTest.php @@ -69,13 +69,13 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { ], ]; $form->setAction(CRM_Core_Action::ADD); - $form->_priceSetId = $this->getPriceSetID('event'); + $form->_priceSetId = $this->getPriceSetID('PaidEvent'); $form->submit([ 'register_date' => date('Ymd'), 'status_id' => 5, 'role_id' => 1, 'event_id' => $form->_eventId, - 'priceSetId' => $this->getPriceSetID('event'), + 'priceSetId' => $this->getPriceSetID('PaidEvent'), $this->getPriceFieldKey() => $this->ids['PriceFieldValue']['price_field'], 'is_pay_later' => 1, 'amount_level' => 'Too much', @@ -103,7 +103,7 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { } $this->assertEquals(55, $sum); - $priceSetID = $this->ids['PriceSet']['event']; + $priceSetID = $this->ids['PriceSet']['PaidEvent']; $eventFeeBlock = CRM_Price_BAO_PriceSet::getSetDetail($priceSetID)[$priceSetID]['fields']; CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $participant['id'], 'participant', $contribution['id'], $eventFeeBlock, $lineItem); // Check that no payment records have been created. @@ -138,10 +138,10 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { // 5. Record the additional amount which $40 ($50-$10) // Expected : Check the amount of new Financial Item created is $40 $this->createParticipantRecordsFromTwoFieldPriceSet(); - $priceSetBlock = CRM_Price_BAO_PriceSet::getSetDetail($this->getPriceSetID('event'), TRUE, FALSE)[$this->getPriceSetID('event')]['fields']; + $priceSetBlock = CRM_Price_BAO_PriceSet::getSetDetail($this->getPriceSetID('PaidEvent'), TRUE, FALSE)[$this->getPriceSetID('PaidEvent')]['fields']; $priceSetParams = [ - 'priceSetId' => $this->getPriceSetID('event'), + 'priceSetId' => $this->getPriceSetID('PaidEvent'), // The 1 & 5 refer to qty as they are text fields. 'price_' . $this->ids['PriceField']['first_text_field'] => 5, 'price_' . $this->ids['PriceField']['second_text_field'] => 1, @@ -303,14 +303,14 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { $submitParams = $this->getSubmitParamsForCreditCardPayment($paymentProcessorID); $submitParams['from_email_address'] = $email['id']; $form->submit($submitParams); - $participantID = Participant::get()->addWhere('event_id', '=', $this->getEventID())->execute()->first()['id']; + $participantID = Participant::get()->addWhere('event_id', '=', $this->getEventID('PaidEvent'))->execute()->first()['id']; //Check if type is correctly populated in mails. //Also check the string email is present not numeric from. $mut->checkMailLog([ 'contactID:::' . $this->getContactID(), 'contact.id:::' . $this->getContactID(), - 'eventID:::' . $this->getEventID(), - 'event.id:::' . $this->getEventID(), + 'eventID:::' . $this->getEventID('PaidEvent'), + 'event.id:::' . $this->getEventID('PaidEvent'), 'participantID:::' . $participantID, 'participant.id:::' . $participantID, '

Test event type - 1

', @@ -394,7 +394,7 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { 'option_amount' => ['1' => $fieldToCreate['amount']], 'option_weight' => ['1' => $fieldToCreate['amount']], 'is_display_amounts' => 1, - 'price_set_id' => $this->getPriceSetID('event'), + 'price_set_id' => $this->getPriceSetID('PaidEvent'), 'is_enter_qty' => 1, 'html_type' => 'Text', 'financial_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Campaign Contribution'), @@ -449,15 +449,15 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { ], ]; $form->setAction(CRM_Core_Action::ADD); - $form->_priceSetId = $this->getPriceSetID('event'); + $form->_priceSetId = $this->getPriceSetID('PaidEvent'); $form->submit([ 'register_date' => date('Ymd'), 'receive_date' => '2018-09-01', 'status_id' => 5, 'role_id' => 1, - 'event_id' => $this->getEventID(), - 'priceSetId' => $this->getPriceSetID('event'), + 'event_id' => $this->getEventID('PaidEvent'), + 'priceSetId' => $this->getPriceSetID('PaidEvent'), 'price_' . $this->ids['PriceField']['first_text_field'] => [$this->ids['PriceFieldValue']['first_text_field'] => 1], 'price_' . $this->ids['PriceField']['second_text_field'] => [$this->ids['PriceFieldValue']['second_text_field'] => 1], 'amount_level' => 'Too much', @@ -479,11 +479,11 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { * @return array */ private function getSubmitParamsForCreditCardPayment(int $paymentProcessorID): array { - $submitParams = [ + return [ 'register_date' => '2018-09-04', 'status_id' => 1, 'role_id' => 1, - 'event_id' => $this->getEventID(), + 'event_id' => $this->getEventID('PaidEvent'), 'credit_card_number' => 4444333322221111, 'cvv2' => 123, 'credit_card_exp_date' => [ @@ -500,7 +500,7 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { 'billing_postal_code-5' => 10545, 'billing_country_id-5' => 1228, 'payment_processor_id' => $paymentProcessorID, - 'priceSetId' => $this->getPriceSetID('event'), + 'priceSetId' => $this->getPriceSetID('PaidEvent'), $this->getPriceFieldKey() => $this->getPriceFieldValueID(), 'amount_level' => 'Too much', 'fee_amount' => $this->formatMoneyInput(1550.55), @@ -509,7 +509,6 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { 'send_receipt' => 1, 'receipt_text' => '', ]; - return $submitParams; } /** @@ -545,12 +544,12 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { public function testSubmitPartialPayment(bool $isQuickConfig): void { $mut = new CiviMailUtils($this, TRUE); $form = $this->getForm(['is_monetary' => 1]); - $this->callAPISuccess('PriceSet', 'create', ['is_quick_config' => $isQuickConfig, 'id' => $this->getPriceSetID('event')]); + $this->callAPISuccess('PriceSet', 'create', ['is_quick_config' => $isQuickConfig, 'id' => $this->getPriceSetID('PaidEvent')]); $paymentInstrumentID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Check'); $submitParams = [ 'hidden_feeblock' => '1', 'hidden_eventFullMsg' => '', - 'priceSetId' => $this->getPriceSetID('event'), + 'priceSetId' => $this->getPriceSetID('PaidEvent'), $this->getPriceFieldKey() => $this->getPriceFieldValueID(), 'check_number' => '879', 'record_contribution' => '1', @@ -567,7 +566,7 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { 'hidden_custom_group_count' => ['' => 1], 'custom_4_-1' => '', 'contact_id' => $this->getContactID(), - 'event_id' => $this->getEventID(), + 'event_id' => $this->getEventID('PaidEvent'), 'campaign_id' => '', 'register_date' => '2020-01-31 00:50:00', 'role_id' => [0 => CRM_Core_PseudoConstant::getKey('CRM_Event_BAO_Participant', 'role_id', 'Attendee')], @@ -592,7 +591,7 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { public function testSubmitPendingPartiallyPaidAddPayment(bool $isQuickConfig): void { $mailUtil = new CiviMailUtils($this, TRUE); $form = $this->getForm(['is_monetary' => 1]); - $this->callAPISuccess('PriceSet', 'create', ['is_quick_config' => $isQuickConfig, 'id' => $this->getPriceSetID('event')]); + $this->callAPISuccess('PriceSet', 'create', ['is_quick_config' => $isQuickConfig, 'id' => $this->getPriceSetID('PaidEvent')]); $paymentInstrumentID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Check'); $form->postProcess(); $this->callAPISuccess('Payment', 'create', [ @@ -618,7 +617,7 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { public function testSubmitPendingAddPayment(bool $isQuickConfig): void { $mailUtil = new CiviMailUtils($this, TRUE); $form = $this->getForm(['is_monetary' => 1]); - $this->callAPISuccess('PriceSet', 'create', ['is_quick_config' => $isQuickConfig, 'id' => $this->getPriceSetID('event')]); + $this->callAPISuccess('PriceSet', 'create', ['is_quick_config' => $isQuickConfig, 'id' => $this->getPriceSetID('PaidEvent')]); $paymentInstrumentID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Check'); $form->postProcess(); $this->callAPISuccess('Payment', 'create', [ @@ -764,7 +763,7 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { return [ 'hidden_feeblock' => '1', 'hidden_eventFullMsg' => '', - 'priceSetId' => $this->getPriceSetID('event'), + 'priceSetId' => $this->getPriceSetID('PaidEvent'), $this->getPriceFieldKey() => $this->getPriceFieldValueID(), 'check_number' => '879', 'record_contribution' => '1', diff --git a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php index 3cfad06593..a80e06d7ce 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php @@ -718,7 +718,7 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase { 'billing_state_province_id-5' => '1061', 'billing_postal_code-5' => '7', 'billing_country_id-5' => '1228', - 'priceSetId' => $this->ids['PriceSet']['event'], + 'priceSetId' => $this->ids['PriceSet']['PaidEvent'], $this->getPriceFieldFormLabel('event_radio') => $this->ids['PriceFieldValue']['hundred'], 'payment_processor_id' => '1', 'year' => '2019', diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index aee9d9fa68..98e59f9462 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1064,7 +1064,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @return array */ - protected function legacyEventCreatePaid(array $params = [], array $options = [['name' => 'hundred', 'amount' => 100]], string $key = 'event'): array { + protected function legacyEventCreatePaid(array $params = [], array $options = [['name' => 'hundred', 'amount' => 100]], string $key = 'PaidEvent'): array { // @todo - uncomment these - but need to fix an e-notice first. // $this->dummyProcessorCreate(); // $params['payment_processor'] = [$this->ids['PaymentProcessor']['dummy_live']]; -- 2.25.1