Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1162 [TEST] [Mailing] add in unit test checking that no bulk email flag is re… #14947

Merged
merged 1 commit into from
Aug 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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