From c9ce39662f13b08f730d1431ed217f2be03458c2 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 18 Sep 2021 08:39:14 +1200 Subject: [PATCH] Remove 'bad' tokens from badge tokens These tokens are a) non-standard, not easily supported b) illogical in the only current core usage context that currently uses these tokens (event badges) c) partially broken - currency returns nothing, note doesn't make sense --- CRM/Core/SelectValues.php | 2 -- CRM/Upgrade/Incremental/MessageTemplates.php | 2 +- tests/phpunit/CRM/Event/Form/Task/BadgeTest.php | 9 +++++++-- tests/phpunit/CRM/Utils/TokenConsistencyTest.php | 2 -- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index ead38069eb..46c63961c6 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -598,8 +598,6 @@ class CRM_Core_SelectValues { '{participant.fee_label}' => 'Fee Label', '{participant.default_role_id}' => 'Default Role', '{participant.template_title}' => 'Event Template Title', - '{participant.currency}' => 'Currency', - '{participant.participant_note}' => 'Participant Note', ]; $customFields = CRM_Core_BAO_CustomField::getFields('Participant'); diff --git a/CRM/Upgrade/Incremental/MessageTemplates.php b/CRM/Upgrade/Incremental/MessageTemplates.php index ff81310c25..a4a0076a8f 100644 --- a/CRM/Upgrade/Incremental/MessageTemplates.php +++ b/CRM/Upgrade/Incremental/MessageTemplates.php @@ -322,7 +322,7 @@ class CRM_Upgrade_Incremental_MessageTemplates { public function replaceTokenInPrintLabel(string $old, string $new): void { $oldToken = '{' . $old . '}'; $newToken = '{' . $new . '}'; - CRM_Core_DAO::executeQuery("UPDATE civicrm_action_schedule + CRM_Core_DAO::executeQuery("UPDATE civicrm_print_label SET data = REPLACE(data, '$oldToken', '$newToken') "); diff --git a/tests/phpunit/CRM/Event/Form/Task/BadgeTest.php b/tests/phpunit/CRM/Event/Form/Task/BadgeTest.php index d5b68ad348..aa0c19763f 100644 --- a/tests/phpunit/CRM/Event/Form/Task/BadgeTest.php +++ b/tests/phpunit/CRM/Event/Form/Task/BadgeTest.php @@ -12,6 +12,11 @@ class CRM_Event_Form_Task_BadgeTest extends CiviUnitTestCase { use CRMTraits_Custom_CustomDataTrait; + public function tearDown(): void { + $this->quickCleanup(['civicrm_participant', 'civicrm_print_label'], TRUE); + parent::tearDown(); + } + /** * Test the the submit function on the event participant submit function. */ @@ -25,7 +30,7 @@ class CRM_Event_Form_Task_BadgeTest extends CiviUnitTestCase { $badgeLayout = PrintLabel::get()->addSelect('data')->execute()->first(); $values = [ - 'data' => array_merge($badgeLayout['data'], ['token' => [], 'font_name' => [''], 'font_size' => [], 'text_alignment' => []]) + 'data' => array_merge($badgeLayout['data'], ['token' => [], 'font_name' => [''], 'font_size' => [], 'text_alignment' => []]), ]; foreach (array_keys($this->getAvailableTokens()) as $id => $token) { $index = $id + 1; @@ -65,7 +70,7 @@ class CRM_Event_Form_Task_BadgeTest extends CiviUnitTestCase { 'text_alignment' => 'C', 'token' => '{event.title}', ], $tokens[1]); - $index =1; + $index = 1; foreach ($this->getAvailableTokens() as $token => $expected) { $this->assertEquals($expected, $tokens[$index]['value'], 'failure in token ' . $token); $index++; diff --git a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php index 91445ed6ed..fa9b57ae4c 100644 --- a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php +++ b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php @@ -495,8 +495,6 @@ December 21st, 2007 '{participant.fee_label}' => 'Fee Label', '{participant.default_role_id}' => 'Default Role', '{participant.template_title}' => 'Event Template Title', - '{participant.currency}' => 'Currency', - '{participant.participant_note}' => 'Participant Note', '{participant.' . $this->getCustomFieldName('text') . '}' => 'Enter text here :: Group with field text', ]; } -- 2.25.1