From bba4f3f65034c3bba0ff891df30ce97fc8a3aa38 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Tue, 10 Jan 2017 13:00:35 +0530 Subject: [PATCH] add unit test --- .../CRM/Core/BAO/ActionScheduleTest.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index b49bda4019..691710c7b7 100644 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -95,6 +95,8 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { 'contact_type' => 'Individual', 'email' => 'test-member@example.com', 'gender_id' => 'Female', + 'first_name' => 'Churmondleia', + 'last_name' => 'Ōtākou', ); $this->fixtures['contact_birthdate'] = array( 'is_deceased' => 0, @@ -603,7 +605,6 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { */ public function tearDown() { parent::tearDown(); - $this->mut->clearMessages(); $this->mut->stop(); unset($this->mut); @@ -621,22 +622,29 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { public function mailerExamples() { $cases = array(); - $manyTokensTmpl = implode(';;', array( + // Some tokens - short as subject has 128char limit in DB. + $someTokensTmpl = implode(';;', array( '{contact.display_name}', // basic contact token '{contact.gender}', // funny legacy contact token '{contact.gender_id}', // funny legacy contact token '{domain.name}', // domain token '{activity.activity_type}', // action-scheduler token )); + // Further tokens can be tested in the body text/html. + $manyTokensTmpl = implode(';;', array( + $someTokensTmpl, + '{contact.email_greeting}', + )); // Note: The behavior of domain-tokens on a scheduled reminder is undefined. All we // can really do is check that it has something. - $manyTokensExpected = 'test-member@example.com;;Female;;Female;;[a-zA-Z0-9 ]+;;Phone Call'; + $someTokensExpected = 'Churmondleia Ōtākou;;Female;;Female;;[a-zA-Z0-9 ]+;;Phone Call'; + $manyTokensExpected = "$someTokensExpected;;Dear Churmondleia"; - // In this example, we use a lot of tokens cutting across multiple components.. + // In this example, we use a lot of tokens cutting across multiple components. $cases[0] = array( // Schedule definition. array( - 'subject' => "subj $manyTokensTmpl", + 'subject' => "subj $someTokensTmpl", 'body_html' => "html $manyTokensTmpl", 'body_text' => "text $manyTokensTmpl", ), @@ -644,7 +652,7 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { array( 'from_name' => "/^FIXME\$/", 'from_email' => "/^info@EXAMPLE.ORG\$/", - 'subject' => "/^subj $manyTokensExpected\$/", + 'subject' => "/^subj $someTokensExpected\$/", 'body_html' => "/^html $manyTokensExpected\$/", 'body_text' => "/^text $manyTokensExpected\$/", ), @@ -755,7 +763,6 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { } } $this->mut->clearMessages(); - } public function testActivityDateTimeMatchNonRepeatableSchedule() { -- 2.25.1