Skip to content

Commit

Permalink
Fall back to system wide information if no default from email can be …
Browse files Browse the repository at this point in the history
…found and no contribution page can be used and no receipt from is passed in and add test to prove it
  • Loading branch information
seamuslee001 committed Feb 17, 2017
1 parent de0c487 commit 4fb4e64
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -4747,6 +4747,9 @@ public static function generateFromEmailAndName($input, $contribution) {
if (!empty($domain['from_email'])) {
return array($domain['from_name'], $domain['from_email']);
}
if (!empty($domain['domain_email'])) {
return array($domain['name'], $domain['domain_email']);
}
$userID = CRM_Core_Session::singleton()->getLoggedInContactID();
$userName = '';
$userEmail = '';
Expand Down
29 changes: 28 additions & 1 deletion tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3427,7 +3427,6 @@ public function testSendMailWithRepeatTransactionAPIFalltoDomain() {
public function testSendMailWithRepeatTransactionAPIFalltoContributionPage() {
$mut = new CiviMailUtils($this, TRUE);
$contributionPage = $this->contributionPageCreate(array('receipt_from_name' => 'CiviCRM LLC', 'receipt_from_email' => 'contributionpage@civicrm.org', 'is_email_receipt' => 1));
$params['contribution_page_id'] = $contributionPage['id'];
$paymentProcessorID = $this->paymentProcessorCreate();
$contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array(
'contact_id' => $this->_individualId,
Expand Down Expand Up @@ -3463,4 +3462,32 @@ public function testSendMailWithRepeatTransactionAPIFalltoContributionPage() {
$mut->stop();
}

/**
* Test sending a mail via the API.
*/
public function testSendMailWithRepeatTransactionAPIFalltoSystemFromNoDefaultFrom() {
$mut = new CiviMailUtils($this, TRUE);
$originalContribution = $contribution = $this->setUpRepeatTransaction(array(), 'single');
$fromEmail = $this->CallAPISuccess('optionValue', 'get', array('is_default' => 1, 'option_group_id' => 'from_email_address', 'sequential' => 1));
foreach ($fromEmail['values'] as $from) {
$this->callAPISuccess('optionValue', 'create', array('is_default' => 0, 'id' => $from['id']));
}
$domain = $this->callAPISuccess('domain', 'getsingle', array('id' => CRM_Core_Config::domainID()));
$this->callAPISuccess('contribution', 'repeattransaction', array(
'contribution_status_id' => 'Completed',
'trxn_id' => uniqid(),
'original_contribution_id' => $originalContribution,
)
);
$mut->checkMailLog(array(
'From: ' . $domain['name'] . ' <' . $domain['domain_email'] . '>',
'Contribution Information',
'Please print this confirmation for your records',
), array(
'Event',
)
);
$mut->stop();
}

}

0 comments on commit 4fb4e64

Please sign in to comment.