Skip to content

Commit

Permalink
Merge pull request #21386 from seamuslee001/test_sendemail
Browse files Browse the repository at this point in the history
[NFC] Extend send email test to cover for contact tokens being replaced
  • Loading branch information
eileenmcnaughton authored Sep 7, 2021
2 parents 592e744 + 36441c0 commit b192487
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions tests/phpunit/CRM/Activity/BAO/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1255,29 +1255,38 @@ public function testSendEmailBasic(): void {
];

$subject = __FUNCTION__ . ' subject';
$html = __FUNCTION__ . ' html';
$text = __FUNCTION__ . ' text';
$html = __FUNCTION__ . ' html {contact.display_name}';
$text = __FUNCTION__ . ' text {contact.display_name}';
$userID = $loggedInUser;

$mut = new CiviMailUtils($this, TRUE);
[$sent, $activity_ids] = CRM_Activity_BAO_Activity::sendEmail(
$contactDetails,
$subject,
$text,
$html,
$contact['email'],
$userID,
$from = __FUNCTION__ . '@example.com'
$from = __FUNCTION__ . '@example.com',
NULL,
NULL,
NULL,
[$contactId]
);

$activity = $this->callAPISuccessGetSingle('Activity', ['id' => $activity_ids[0], 'return' => ['details', 'subject']]);
$details = "-ALTERNATIVE ITEM 0-
$html
$details = '-ALTERNATIVE ITEM 0-
' . __FUNCTION__ . ' html ' . $contact['display_name'] . '
-ALTERNATIVE ITEM 1-
$text
' . __FUNCTION__ . ' text ' . $contact['display_name'] . '
-ALTERNATIVE END-
";
$this->assertEquals($activity['details'], $details, 'Activity details does not match.');
$this->assertEquals($activity['subject'], $subject, 'Activity subject does not match.');
';
$this->assertEquals($details, $activity['details'], 'Activity details does not match.');
$this->assertEquals($subject, $activity['subject'], 'Activity subject does not match.');
$mut->checkMailLog([
'Mr. Anthony Anderson',
]);
$mut->stop();
}

public function testSendEmailWithCampaign() {
Expand Down

0 comments on commit b192487

Please sign in to comment.