From 02a459c55ccef41d7d5c704d953ee625a4991a3b Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 5 Sep 2017 01:14:52 +1200 Subject: [PATCH] Reinstate accidentally deleted test. This got deleted in renaming a file, re-adding --- tests/phpunit/CRM/Utils/TokenTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/phpunit/CRM/Utils/TokenTest.php b/tests/phpunit/CRM/Utils/TokenTest.php index f6df7d0122..795ce797f0 100644 --- a/tests/phpunit/CRM/Utils/TokenTest.php +++ b/tests/phpunit/CRM/Utils/TokenTest.php @@ -56,6 +56,30 @@ class CRM_Utils_TokenTest extends CiviUnitTestCase { Civi::settings()->set('searchPrimaryDetailsOnly', '1'); } + /** + * Test for replaceGreetingTokens. + * + */ + public function testReplaceGreetingTokens() { + $tokenString = 'First Name: {contact.first_name} Last Name: {contact.last_name} Birth Date: {contact.birth_date} Prefix: {contact.prefix_id} Suffix: {contact.individual_suffix}'; + $contactDetails = array( + array( + 2811 => array( + 'id' => '2811', + 'contact_type' => 'Individual', + 'first_name' => 'Morticia', + 'last_name' => 'Addams', + 'prefix_id' => 2, + ), + ), + ); + $contactId = 2811; + $className = 'CRM_Contact_BAO_Contact'; + $escapeSmarty = TRUE; + CRM_Utils_Token::replaceGreetingTokens($tokenString, $contactDetails, $contactId, $className, $escapeSmarty); + $this->assertEquals($tokenString, 'First Name: Morticia Last Name: Addams Birth Date: Prefix: Ms. Suffix: '); + } + /** * Test getting multiple contacts. * -- 2.25.1