Reinstate accidentally deleted test.
authoreileen <emcnaughton@wikimedia.org>
Mon, 4 Sep 2017 13:14:52 +0000 (01:14 +1200)
committereileen <emcnaughton@wikimedia.org>
Mon, 4 Sep 2017 13:14:52 +0000 (01:14 +1200)
This got deleted in renaming a file, re-adding

tests/phpunit/CRM/Utils/TokenTest.php

index f6df7d0122ea03ddc2a1d4dc125db29a3ea580b4..795ce797f03cc1aa378afbe0f0ccecb1530eed3a 100644 (file)
@@ -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.
    *