From: Eileen McNaughton Date: Mon, 18 Sep 2023 00:11:06 +0000 (+1200) Subject: Add test cover, use token for event.is_share X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6f98a260f3826bf643e8d3b92be2588d78026d0c;p=civicrm-core.git Add test cover, use token for event.is_share Also fix a couple of places where is_monetary is using the smarty variable. We have updated & tested is_monetary elsewhere --- diff --git a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php index 88ee9eebee..ed1d2a61fe 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php @@ -25,15 +25,22 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase { * Initial test of submit function. */ public function testSubmit(): void { - $mut = new CiviMailUtils($this, TRUE); $this->submitPaidEvent(); - - $mut->checkMailLog([ + $this->assertSentMailHasStrings([ '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', + 'Add event to Google Calendar', ]); - $mut->stop(); - $mut->clearMessages(); + } + + public function assertSentMailHasStrings(array $strings): void { + foreach ($strings as $string) { + $this->assertSentMailHasString($string); + } + } + + public function assertSentMailHasString(string $string): void { + $this->assertStringContainsString($string, $this->sentMail[0]); } /** @@ -645,6 +652,7 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase { * @param array $submitValues */ protected function submitPaidEvent(array $submitValues = []): void { + $mailUtil = new CiviMailUtils($this, TRUE); $this->dummyProcessorCreate(); $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([ @@ -669,6 +677,7 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase { 'billing_state_province-5' => 'AP', 'billing_country-5' => 'US', ], $submitValues)); + $this->sentMail = $mailUtil->getAllMessages(); } public function testRegistrationWithoutCiviContributeEnabled(): void { diff --git a/tests/phpunit/CiviTest/CiviMailUtils.php b/tests/phpunit/CiviTest/CiviMailUtils.php index 0c4c23eee9..347f7b2935 100644 --- a/tests/phpunit/CiviTest/CiviMailUtils.php +++ b/tests/phpunit/CiviTest/CiviMailUtils.php @@ -124,9 +124,10 @@ class CiviMailUtils extends PHPUnit\Framework\TestCase { * @param string $type * 'raw'|'ezc'. * - * @throws CRM_Core_Exception - * * @return array(ezcMail)|array(string) + * + * @noinspection PhpMissingReturnTypeInspection + * @noinspection PhpDocMissingThrowsInspection */ public function getAllMessages($type = 'raw') { $msgs = []; diff --git a/xml/templates/message_templates/event_offline_receipt_text.tpl b/xml/templates/message_templates/event_offline_receipt_text.tpl index 8ce9fb265d..bd780138f4 100644 --- a/xml/templates/message_templates/event_offline_receipt_text.tpl +++ b/xml/templates/message_templates/event_offline_receipt_text.tpl @@ -84,7 +84,7 @@ {$email} {/if} -{if !empty($event.is_monetary)} {* This section for Paid events only.*} +{if {event.is_monetary|boolean}} {* This section for Paid events only.*} ==========================================================={if !empty($pricesetFieldsCount) }===================={/if} diff --git a/xml/templates/message_templates/event_online_receipt_html.tpl b/xml/templates/message_templates/event_online_receipt_html.tpl index fe6646f37f..daa8aab8a9 100644 --- a/xml/templates/message_templates/event_online_receipt_html.tpl +++ b/xml/templates/message_templates/event_online_receipt_html.tpl @@ -157,7 +157,7 @@ {/if} - {if $event.is_share} + {if {event.is_share|boolean}} {capture assign=eventUrl}{crmURL p='civicrm/event/info' q="id={event.id}&reset=1" a=true fe=1 h=1}{/capture} diff --git a/xml/templates/message_templates/event_online_receipt_text.tpl b/xml/templates/message_templates/event_online_receipt_text.tpl index fcc713f2bc..db1d19037e 100644 --- a/xml/templates/message_templates/event_online_receipt_text.tpl +++ b/xml/templates/message_templates/event_online_receipt_text.tpl @@ -96,7 +96,7 @@ {if !empty($payer.name)} You were registered by: {$payer.name} {/if} -{if !empty($event.is_monetary) and empty($isRequireApproval)} {* This section for Paid events only.*} +{if {event.is_monetary|boolean} and empty($isRequireApproval)} {* This section for Paid events only.*} ==========================================================={if !empty($pricesetFieldsCount)}===================={/if}