dev/core#448 Add in a Unit test to demonstrate the problem with smart groups and...
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 16 Oct 2018 20:01:41 +0000 (07:01 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 16 Oct 2018 20:01:41 +0000 (07:01 +1100)
tests/phpunit/CRM/Mailing/BAO/MailingTest.php

index 937babbf025f7db6e1b281c0dc4feeeffd6c1145..0d00874b44f8b146f13159656f9d7fd94a95f099 100644 (file)
@@ -397,6 +397,21 @@ class CRM_Mailing_BAO_MailingTest extends CiviUnitTestCase {
     unset($expected[0], $expected[4], $expected[8]);
     $this->assertRecipientsCorrect($mailing['id'], $expected);
 
+    // Tear down: delete mailing, groups, contacts
+    $this->deleteMailing($mailing['id']);
+
+    // Create a New mailing, Testing contacts removed from smart group.
+    // In this case groupIDs6 will only pick up contacts[0] amd contacts[8] with it's
+    // criteria. However we are deliberly going to remove contactIds[8] from the group
+    // Which should mean the mainling only finds 1 contact that is contactIds[0]
+    $mailing = $this->callAPISuccess('Mailing', 'create', array());
+    $this->callAPISuccess('GroupContact', 'Create', array(
+      'group_id' => $groupIDs[6],
+      'contact_id' => $contactIDs[8],
+      'status' => 'Removed',
+    ));
+    $this->createMailingGroup($mailing['id'], $groupIDs[6]);
+    $this->assertRecipientsCorrect($mailing['id'], [$contactIDs[0]]);
     // Tear down: delete mailing, groups, contacts
     $this->deleteMailing($mailing['id']);
     foreach ($groupIDs as $groupID) {