From 206a21e86ea97898ea76462a10497864caa4bcd9 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Fri, 8 Nov 2019 15:59:24 -0500 Subject: [PATCH] dev/core#1378 Scheduled reminders: test to not email if do_not_email or is_deceased --- .../CRM/Activity/ActionMappingTest.php | 37 +++++++++++++++++++ .../ActionSchedule/AbstractMappingTest.php | 14 +++++++ 2 files changed, 51 insertions(+) diff --git a/tests/phpunit/CRM/Activity/ActionMappingTest.php b/tests/phpunit/CRM/Activity/ActionMappingTest.php index 071efe5876..ff7cb2e1fa 100644 --- a/tests/phpunit/CRM/Activity/ActionMappingTest.php +++ b/tests/phpunit/CRM/Activity/ActionMappingTest.php @@ -141,6 +141,13 @@ class CRM_Activity_ActionMappingTest extends \Civi\ActionSchedule\AbstractMappin ], ]; + // No recipients: Dave has `do_not_email` and Edith is dead. + $cs[] = [ + '2015-02-01 00:00:00', + 'addDaveMeeting addEdithMeeting scheduleForMeeting startOnTime useHelloFirstName recipientIsActivitySource', + [], + ]; + return $cs; } @@ -172,6 +179,36 @@ class CRM_Activity_ActionMappingTest extends \Civi\ActionSchedule\AbstractMappin ]); } + /** + * Create an activity record for Dave with type "Meeting". Dave has + * "do_not_email" set, so he should never receive an email reminder. + */ + public function addDaveMeeting() { + $this->callAPISuccess('Activity', 'create', [ + 'source_contact_id' => $this->contacts['dave']['id'], + 'activity_type_id' => 'Meeting', + 'subject' => 'Subject for Dave', + 'activity_date_time' => date('Y-m-d H:i:s', strtotime($this->targetDate)), + 'status_id' => 2, + 'assignee_contact_id' => [$this->contacts['carol']['id']], + ]); + } + + /** + * Create an activity record for Edith with type "Meeting". Edith is dead, so + * she should never receive an email reminder. + */ + public function addEdithMeeting() { + $this->callAPISuccess('Activity', 'create', [ + 'source_contact_id' => $this->contacts['edith']['id'], + 'activity_type_id' => 'Meeting', + 'subject' => 'Subject for Edith', + '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". */ diff --git a/tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php b/tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php index 5483a2e58a..43104f6922 100644 --- a/tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php +++ b/tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php @@ -227,6 +227,20 @@ abstract class AbstractMappingTest extends \CiviUnitTestCase { 'last_name' => 'Exemplar', 'email' => 'carol@example.org', ]); + $this->contacts['dave'] = $this->callAPISuccess('Contact', 'create', [ + 'contact_type' => 'Individual', + 'first_name' => 'Dave', + 'last_name' => 'Exemplar', + 'email' => 'dave@example.org', + 'do_not_email' => 1, + ]); + $this->contacts['edith'] = $this->callAPISuccess('Contact', 'create', [ + 'contact_type' => 'Individual', + 'first_name' => 'Edith', + 'last_name' => 'Exemplar', + 'email' => 'edith@example.org', + 'is_deceased' => 1, + ]); } /** -- 2.25.1