Skip to content

Commit

Permalink
Merge pull request #14947 from seamuslee001/lab_core_1162
Browse files Browse the repository at this point in the history
dev/core#1162 [TEST] [Mailing] add in unit test checking that no bulk email flag is re…
  • Loading branch information
seamuslee001 authored Aug 2, 2019
2 parents 108a8c9 + 30b036f commit 9b4d283
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/phpunit/CRM/Mailing/BAO/MailingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,49 @@ public function testgetRecipientsEmailGroupIncludeExclude() {
}
}

/**
* Test That No BUlk Emails User Optt Out is resepected when constructing a mailing
*/
public function testGetReceipientNoBulkEmails() {
// Set up groups; 3 standard, 4 smart
$groupIDs = [];
$params = [
'name' => 'Test static group 1',
'title' => 'Test static group 1',
'is_active' => 1,
];
$groupIDs[] = $this->groupCreate($params);

// Create contacts
$contactIDs = [
$this->individualCreate(['last_name' => 'test_contact1'], 0),
$this->individualCreate(['last_name' => 'test_contact2', 'is_opt_out' => 1], 1),
];

// Add contacts to static groups
$this->callAPISuccess('GroupContact', 'Create', [
'group_id' => $groupIDs[0],
'contact_id' => $contactIDs[0],
]);
$this->callAPISuccess('GroupContact', 'Create', [
'group_id' => $groupIDs[0],
'contact_id' => $contactIDs[1],
]);

// Check that we can include static groups in the mailing.
// Expected: Contacts [0-3] should be included.
$mailing = $this->callAPISuccess('Mailing', 'create', []);
$this->createMailingGroup($mailing['id'], $groupIDs[0]);
$this->assertRecipientsCorrect($mailing['id'], [$contactIDs[0]]);
$this->deleteMailing($mailing['id']);
foreach ($groupIDs as $groupID) {
$this->groupDelete($groupID);
}
foreach ($contactIDs as $contactID) {
$this->contactDelete($contactID);
}
}

/**
* Test CRM_Mailing_BAO_Mailing::getRecipients() on sms mode
*/
Expand Down

0 comments on commit 9b4d283

Please sign in to comment.