From 32d1feb3ac7e678c0b1d6ad55b1a5e1e09f7c94b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 4 Aug 2023 11:55:36 +1200 Subject: [PATCH] Fix event templates to use end_date token --- Civi/Test/EventTestTrait.php | 2 +- tests/phpunit/CRM/Event/Form/ParticipantTest.php | 13 +++++++------ .../CRM/Event/Form/Registration/ConfirmTest.php | 3 ++- .../message_templates/event_online_receipt_text.tpl | 2 +- .../event_offline_receipt_html.tpl | 2 +- .../event_offline_receipt_text.tpl | 2 +- .../message_templates/event_online_receipt_html.tpl | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Civi/Test/EventTestTrait.php b/Civi/Test/EventTestTrait.php index 93b711faff92..e245c20d5e2b 100644 --- a/Civi/Test/EventTestTrait.php +++ b/Civi/Test/EventTestTrait.php @@ -59,7 +59,7 @@ protected function eventCreatePaid(array $eventParameters = [], array $priceSetP $event = $this->eventCreate($eventParameters, $identifier); if (array_keys($priceSetParameters) !== ['id']) { try { - $this->eventCreatePriceSet([], $identifier); + $this->eventCreatePriceSet($priceSetParameters, $identifier); $this->setTestEntityID('PriceSetEntity', PriceSetEntity::create(FALSE) ->setValues([ 'entity_table' => 'civicrm_event', diff --git a/tests/phpunit/CRM/Event/Form/ParticipantTest.php b/tests/phpunit/CRM/Event/Form/ParticipantTest.php index 290c8ee589cb..4155eef8397c 100644 --- a/tests/phpunit/CRM/Event/Form/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/Form/ParticipantTest.php @@ -349,12 +349,13 @@ public function testParticipantOfflineReceipt(string $thousandSeparator): void { * * @param array $eventParams * @param array $submittedValues + * @param bool $isQuickConfig * * @return CRM_Event_Form_Participant * * @throws \CRM_Core_Exception */ - protected function getForm(array $eventParams = [], array $submittedValues = []): CRM_Event_Form_Participant { + protected function getForm(array $eventParams = [], array $submittedValues = [], bool $isQuickConfig = FALSE): CRM_Event_Form_Participant { $submittedValues['contact_id'] = $this->ids['Contact']['event'] = $this->individualCreate(); if (!empty($eventParams['is_monetary'])) { @@ -365,7 +366,7 @@ protected function getForm(array $eventParams = [], array $submittedValues = []) 'loc_block_id' => $locationBlockID, 'confirm_email_text' => "Just do it\n Now", 'is_show_location' => TRUE, - ], $eventParams)); + ], $eventParams), ['is_quick_config' => $isQuickConfig]); $submittedValues = array_merge($this->getRecordContributionParams('Partially paid', 'Pending'), $submittedValues); } else { @@ -549,7 +550,7 @@ public function testSubmitWithDeferredRecognition(): void { */ public function testSubmitPartialPayment(bool $isQuickConfig): void { $mut = new CiviMailUtils($this, TRUE); - $form = $this->getForm(['is_monetary' => 1]); + $form = $this->getForm(['is_monetary' => 1, 'start_date' => '2023-02-15 15:00', 'end_date' => '2023-02-15 18:00']); $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 = [ @@ -596,8 +597,7 @@ public function testSubmitPartialPayment(bool $isQuickConfig): void { */ 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('PaidEvent')]); + $form = $this->getForm(['is_monetary' => 1, 'start_date' => '2023-02-15 15:00', 'end_date' => '2023-02-15 18:00'], [], $isQuickConfig); $paymentInstrumentID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Check'); $form->postProcess(); $this->callAPISuccess('Payment', 'create', [ @@ -622,7 +622,7 @@ public function testSubmitPendingPartiallyPaidAddPayment(bool $isQuickConfig): v */ public function testSubmitPendingAddPayment(bool $isQuickConfig): void { $mailUtil = new CiviMailUtils($this, TRUE); - $form = $this->getForm(['is_monetary' => 1]); + $form = $this->getForm(['is_monetary' => 1, 'start_date' => '2023-02-15 15:00', 'end_date' => '2023-02-15 18:00']); $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(); @@ -727,6 +727,7 @@ protected function assertPartialPaymentResult(bool $isQuickConfig, CiviMailUtils $isAmountPaidOnForm ? 'Balance: $1,530.55' : 'Balance: $1,550.55', 'Financial Type: Event Fee', 'Paid By: Check', + 'February 15th, 2023 3:00 PM- 6:00 PM', 'Check Number: 879', ]); } diff --git a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php index cd26c5508633..a2421ce729ca 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php @@ -25,6 +25,7 @@ public function testSubmit(): void { $mut->checkMailLog([ 'Dear Kim, Thank you for your registration. This is a confirmation that your registration has been received and your status has been updated to Registered.', + 'Friday September 16th, 2022 12:00 PM-Saturday September 17th, 2022 12:00 PM', ]); $mut->stop(); $mut->clearMessages(); @@ -696,7 +697,7 @@ protected function submitForm(int $eventID, array $submittedValues): void { */ protected function submitPaidEvent(array $submitValues = []): void { $this->dummyProcessorCreate(); - $event = $this->eventCreatePaid(['payment_processor' => [$this->ids['PaymentProcessor']['dummy_live']], 'confirm_email_text' => '', 'is_pay_later' => FALSE]); + $event = $this->eventCreatePaid(['payment_processor' => [$this->ids['PaymentProcessor']['dummy_live']], 'confirm_email_text' => '', 'is_pay_later' => FALSE, 'start_date' => '2022-09-16 12:00', 'end_date' => '2022-09-17 12:00']); $this->submitForm($event['id'], array_merge([ 'email-Primary' => 'demo@example.com', 'credit_card_number' => '4111111111111111', diff --git a/tests/templates/message_templates/event_online_receipt_text.tpl b/tests/templates/message_templates/event_online_receipt_text.tpl index 808793b2c25a..83cc539cc083 100644 --- a/tests/templates/message_templates/event_online_receipt_text.tpl +++ b/tests/templates/message_templates/event_online_receipt_text.tpl @@ -34,7 +34,7 @@ pay_later_receipt:::{$pay_later_receipt} {/if} event.event_title:::{$event.event_title} event.event_start_date:::{$event.event_start_date|crmDate:"%A"} -event.event_end_date:::{$event.event_end_date|crmDate:"%Y%m%d"} +event.event_end_date:::{event.end_date|crmDate:"%Y%m%d"} {if isset($event.is_monetary)} event.is_monetary:::{$event.is_monetary} {/if} diff --git a/xml/templates/message_templates/event_offline_receipt_html.tpl b/xml/templates/message_templates/event_offline_receipt_html.tpl index 62887a20d2cd..f5f1e1b138a8 100644 --- a/xml/templates/message_templates/event_offline_receipt_html.tpl +++ b/xml/templates/message_templates/event_offline_receipt_html.tpl @@ -49,7 +49,7 @@ {event.title}
- {event.start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|crmDate:"%Y%m%d" == $event.event_start_date|crmDate:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} + {event.start_date|crmDate}{if {event.end_date|boolean}}-{if '{event.end_date|crmDate:"%Y%m%d"}' === '{event.start_date|crmDate:"%Y%m%d"}'}{event.end_date|crmDate:"Time"}{else}{event.end_date}{/if}{/if} diff --git a/xml/templates/message_templates/event_offline_receipt_text.tpl b/xml/templates/message_templates/event_offline_receipt_text.tpl index c6f5a8550bad..1cdefde59e9d 100644 --- a/xml/templates/message_templates/event_offline_receipt_text.tpl +++ b/xml/templates/message_templates/event_offline_receipt_text.tpl @@ -38,7 +38,7 @@ ==========================================================={if !empty($pricesetFieldsCount) }===================={/if} {event.title} -{event.start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|crmDate:"%Y%m%d" == $event.event_start_date|crmDate:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} +{event.start_date|crmDate}{if {event.end_date|boolean}}-{if '{event.end_date|crmDate:"%Y%m%d"}' === '{event.start_date|crmDate:"%Y%m%d"}'}{event.end_date|crmDate:"Time"}{else}{event.end_date}{/if}{/if} {if !empty($event.participant_role) and $event.participant_role neq 'Attendee' and empty($defaultRole)} {ts}Participant Role{/ts}: {$event.participant_role} diff --git a/xml/templates/message_templates/event_online_receipt_html.tpl b/xml/templates/message_templates/event_online_receipt_html.tpl index df251a602b7f..ad8f0aadf4b7 100644 --- a/xml/templates/message_templates/event_online_receipt_html.tpl +++ b/xml/templates/message_templates/event_online_receipt_html.tpl @@ -64,7 +64,7 @@ {event.title}
- {event.start_date|crmDate:"%A"} {event.start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|crmDate:"%Y%m%d" == $event.event_start_date|crmDate:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate:"%A"} {$event.event_end_date|crmDate}{/if}{/if} + {event.start_date|crmDate:"%A"} {event.start_date|crmDate}{if {event.end_date|boolean}}-{if '{event.end_date|crmDate:"%Y%m%d"}' === '{event.start_date|crmDate:"%Y%m%d"}'}{event.end_date|crmDate:"Time"}{else}{event.end_date|crmDate:"%A"} {event.end_date|crmDate}{/if}{/if}