add unit test
authorChris Burgess <chris@fuzion.co.nz>
Tue, 10 Jan 2017 07:30:35 +0000 (13:00 +0530)
committerdeb.monish <monish.deb@webaccessglobal.com>
Thu, 12 Jan 2017 14:32:46 +0000 (20:02 +0530)
tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php

index b49bda4019b0e30ea49d63afc47f75732c868487..691710c7b7b63f63f55f0a4919c295a6e948d75e 100644 (file)
@@ -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() {