From: Seamus Lee Date: Mon, 7 Jan 2019 03:41:25 +0000 (+1100) Subject: (dev/core#644) Add in unit test showing backend able to handle user email address... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7401dffa6da1e2f85b66d0e1a57527e76c0cff1a;p=civicrm-core.git (dev/core#644) Add in unit test showing backend able to handle user email address as from email sensibly --- diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index b207862296..8904cf1ccf 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -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( + '

Please print this receipt for your records.

', + '', + ) + ); + $mut->stop(); + } + /** * Ensure that price field are shown during pay later/pending Contribution */