Add actionschedule test for activity tokens
authorMatthew Wire <mjw@mjwconsult.co.uk>
Wed, 11 Aug 2021 04:07:47 +0000 (21:07 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 11 Aug 2021 04:12:02 +0000 (21:12 -0700)
tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php

index e069adb6783392d78ae62e434dddd3acd99f71d9..838f7541d199f890cdd88ecc3c0f3448e1188c3e 100644 (file)
@@ -112,6 +112,8 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase {
       'activity_date_time' => '20120615100000',
       'is_current_revision' => 1,
       'is_deleted' => 0,
+      'subject' => 'Phone call',
+      'details' => 'A phone call about a bear',
     ];
     $this->fixtures['contact'] = [
       'is_deceased' => 0,
@@ -957,6 +959,27 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase {
       ],
     ];
 
+    // In this example, we test activity tokens
+    $activityTokens = '{activity.subject};;{activity.details};;{activity.activity_date_time}';
+    $activity = $this->fixtures['phonecall'];
+    $activityTokensExpected = "Phone call;;A phone call about a bear;;June 15th, 2012 10:00 AM";
+    $cases[4] = [
+      // Schedule definition.
+      [
+        'subject' => "subj $someTokensTmpl",
+        'body_html' => "html {$activityTokens}",
+        'body_text' => "text {$activityTokens}",
+      ],
+      // Assertions (regex).
+      [
+        'from_name' => '/^FIXME$/',
+        'from_email' => '/^info@EXAMPLE.ORG$/',
+        'subject' => "/^subj $someTokensExpected\$/",
+        'body_html' => "/^html $activityTokensExpected\$/",
+        'body_text' => "/^text $activityTokensExpected\$/",
+      ],
+    ];
+
     return $cases;
   }