From 24bf3d3fc18d09b9d443effaad8e54f0586bf4cb Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 10 Aug 2021 21:07:47 -0700 Subject: [PATCH] Add actionschedule test for activity tokens --- .../CRM/Core/BAO/ActionScheduleTest.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index e069adb678..838f7541d1 100644 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -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; } -- 2.25.1