dev/core#1378 Scheduled reminders: test to not send if email is on hold
authorAndrew Hunt <andrew@aghstrategies.com>
Fri, 8 Nov 2019 21:31:17 +0000 (16:31 -0500)
committerAndrew Hunt <andrew@aghstrategies.com>
Fri, 8 Nov 2019 21:53:06 +0000 (16:53 -0500)
tests/phpunit/CRM/Activity/ActionMappingTest.php
tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php

index ff7cb2e1faadad954158ad8b931dd0c526f5c732..2ec8b7d1712e21c7fb44b9da805af0f64c83e70a 100644 (file)
@@ -141,10 +141,11 @@ class CRM_Activity_ActionMappingTest extends \Civi\ActionSchedule\AbstractMappin
       ],
     ];
 
-    // No recipients: Dave has `do_not_email` and Edith is dead.
+    // No recipients: Dave has `do_not_email`, Edith is dead, and Francis' email
+    // is on hold.
     $cs[] = [
       '2015-02-01 00:00:00',
-      'addDaveMeeting addEdithMeeting scheduleForMeeting startOnTime useHelloFirstName recipientIsActivitySource',
+      'addDaveMeeting addEdithMeeting addFrancisMeeting scheduleForMeeting startOnTime useHelloFirstName recipientIsActivitySource',
       [],
     ];
 
@@ -209,6 +210,21 @@ class CRM_Activity_ActionMappingTest extends \Civi\ActionSchedule\AbstractMappin
     ]);
   }
 
+  /**
+   * Create an activity record for Francis with type "Meeting". Francis' email
+   * is misspelled and has bounced, so he should never receive an email reminder.
+   */
+  public function addFrancisMeeting() {
+    $this->callAPISuccess('Activity', 'create', [
+      'source_contact_id' => $this->contacts['francis']['id'],
+      'activity_type_id' => 'Meeting',
+      'subject' => 'Subject for Francis',
+      'activity_date_time' => date('Y-m-d H:i:s', strtotime($this->targetDate)),
+      'status_id' => 2,
+      'assignee_contact_id' => [$this->contacts['carol']['id']],
+    ]);
+  }
+
   /**
    * Schedule message delivery for activities of type "Meeting".
    */
index 43104f6922dd31b38c3e777e28909fa98fa115da..e30b2bb75666685882e070ae1918a129fda47356 100644 (file)
@@ -241,6 +241,15 @@ abstract class AbstractMappingTest extends \CiviUnitTestCase {
       'email' => 'edith@example.org',
       'is_deceased' => 1,
     ]);
+    $this->contacts['francis'] = $this->callAPISuccess('Contact', 'create', [
+      'contact_type' => 'Individual',
+      'first_name' => 'Francis',
+      'last_name' => 'Exemplar',
+      'api.Email.create' => [
+        'email' => 'frances@example.org',
+        'on_hold' => 1,
+      ],
+    ]);
   }
 
   /**