(dev/core#644) Add in unit test showing backend able to handle user email address...
authorSeamus Lee <seamuslee001@gmail.com>
Mon, 7 Jan 2019 03:41:25 +0000 (14:41 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Mon, 7 Jan 2019 03:41:25 +0000 (14:41 +1100)
tests/phpunit/CRM/Contribute/Form/ContributionTest.php

index b207862296b3c62dbf8fc11e4b257e89ee29d392..8904cf1ccfe5cb8cd77444ec3a70d9682deb4c1c 100644 (file)
@@ -45,6 +45,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase {
   protected $_params;
   protected $_ids = array();
   protected $_pageParams = array();
+  protected $_userId;
 
   /**
    * Parameters to create payment processor.
@@ -94,7 +95,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase {
   public function setUp() {
     $this->_apiversion = 3;
     parent::setUp();
-    $this->createLoggedInUser();
+    $this->_userId = $this->createLoggedInUser();
 
     $this->_individualId = $this->individualCreate();
     $this->_params = array(
@@ -625,6 +626,33 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase {
     $mut->stop();
   }
 
+  /**
+   * Test the submit function on the contribution page using numerical from email address.
+   */
+  public function testSubmitEmailReceiptUserEmailFromAddress() {
+    $form = new CRM_Contribute_Form_Contribution();
+    $mut = new CiviMailUtils($this, TRUE);
+    $email = $this->callAPISuccess('Email', 'create', [
+      'contact_id' => $this->_userId,
+      'email' => 'testLoggedIn@example.com',
+    ]);
+    $form->testSubmit(array(
+      'total_amount' => 50,
+      'financial_type_id' => 1,
+      'contact_id' => $this->_individualId,
+      'is_email_receipt' => TRUE,
+      'from_email_address' => $email['id'],
+      'contribution_status_id' => 1,
+    ), CRM_Core_Action::ADD);
+    $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1);
+    $mut->checkMailLog(array(
+        '<p>Please print this receipt for your records.</p>',
+        '<testloggedin@example.com>',
+      )
+    );
+    $mut->stop();
+  }
+
   /**
    * Ensure that price field are shown during pay later/pending Contribution
    */