Fall back to system wide information if no default from email can be found and no...
authorSeamus Lee <seamuslee001@gmail.com>
Fri, 17 Feb 2017 21:52:26 +0000 (08:52 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 17 Feb 2017 21:52:26 +0000 (08:52 +1100)
CRM/Contribute/BAO/Contribution.php
tests/phpunit/api/v3/ContributionTest.php

index 8a611f35ed40341ebd9b7a7aea254869be8b9c30..a6b72f66c7e0e8386a7166f85496b1b645489418 100644 (file)
@@ -4747,6 +4747,9 @@ LIMIT 1;";
     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 = '';
index c6b662725045b5f9b2ed6cd3735b8708eb4b4869..18040298efcbbc94d1b652dba67b52718cc776cf 100644 (file)
@@ -3427,7 +3427,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
   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,
@@ -3463,4 +3462,32 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     $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();
+  }
+
 }