From e0d5e019896d3a92ca6cd25c65276adcd56cceef Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 16 May 2023 18:42:02 +1200 Subject: [PATCH] Add deceased date token Per https://github.com/eileenmcnaughton/nz.co.fuzion.civitoken/issues/63 --- CRM/Contact/Tokens.php | 1 + tests/phpunit/CRM/Core/BAO/MessageTemplateTest.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/Tokens.php b/CRM/Contact/Tokens.php index de25925709..97d87b2d93 100644 --- a/CRM/Contact/Tokens.php +++ b/CRM/Contact/Tokens.php @@ -168,6 +168,7 @@ class CRM_Contact_Tokens extends CRM_Core_EntityTokens { 'job_title', 'gender_id', 'birth_date', + 'deceased_date', 'employer_id', 'is_deleted', 'created_date', diff --git a/tests/phpunit/CRM/Core/BAO/MessageTemplateTest.php b/tests/phpunit/CRM/Core/BAO/MessageTemplateTest.php index 73a2650df0..1e143518ad 100644 --- a/tests/phpunit/CRM/Core/BAO/MessageTemplateTest.php +++ b/tests/phpunit/CRM/Core/BAO/MessageTemplateTest.php @@ -483,6 +483,7 @@ emo $this->assertEquals($expected_parts[0], $returned_parts[0]); $this->assertApproxEquals($expected_parts[1], $returned_parts[1], 2); $this->assertEquals($expected_parts[2], $returned_parts[2]); + $restoreTime->cleanup(); } /** @@ -538,6 +539,7 @@ emo 'contact.contact_is_deleted:', 'contact.county:', 'contact.custom_6:', + 'contact.deceased_date:', 'contact.do_not_phone:', ], array_values($emptyLines), 'Most tokens should have data.'); } @@ -703,6 +705,7 @@ emo '{contact.job_title}' => 'Job Title', '{contact.gender_id:label}' => 'Gender', '{contact.birth_date}' => 'Birth Date', + '{contact.deceased_date}' => 'Deceased Date', '{contact.employer_id}' => 'Current Employer ID', '{contact.is_deleted:label}' => 'Contact is in Trash', '{contact.created_date}' => 'Created Date', @@ -889,8 +892,6 @@ emo * advertise them and the old 'random' v3 style tokens continued to work. * * But, we should support them for a bit - which means testing them... - * - * @throws \CRM_Core_Exception */ public function testBrieflyPopularTokens(): void { $this->createCustomGroupWithFieldsOfAllTypes([]); @@ -1096,6 +1097,7 @@ communication_style_id:label |Formal job_title |Busy person gender_id:label |Female birth_date |December 31st, 1998 +deceased_date | employer_id |' . $contact['employer_id'] . ' is_deleted:label |No created_date |January 1st, 2020 -- 2.25.1