From: Eileen McNaughton Date: Sun, 3 May 2015 10:05:03 +0000 (+1200) Subject: CRM-16367 (Backoffice contribution page) get premium code email under unit test X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=43bf07d6fa0ff45205696b1f0af5d245e546e669;p=civicrm-core.git CRM-16367 (Backoffice contribution page) get premium code email under unit test --- diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index c3b971d3d3..70678d1b8b 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -29,8 +29,6 @@ * * @package CRM * @copyright CiviCRM LLC (c) 2004-2015 - * $Id$ - * */ /** diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index 8da21e9c8e..448f05bc4d 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -375,12 +375,13 @@ class CRM_Contribute_Form_AdditionalInfo { ) { $productDAO = new CRM_Contribute_DAO_Product(); $productDAO->id = $params['product_name'][0]; + $productOptionID = $params['product_name'][1]; $productDAO->find(TRUE); $params['product_name'] = $productDAO->name; $params['product_sku'] = $productDAO->sku; - if (empty($params['product_option']) && !empty($form->_options[$params['product_name'][0]])) { - $params['product_option'] = $form->_options[$params['product_name'][0]][$params['product_name'][1]]; + if (empty($params['product_option']) && !empty($form->_options[$productDAO->id])) { + $params['product_option'] = $form->_options[$productDAO->id][$productOptionID]; } } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 2d4688c2cf..a8baae0ab6 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1411,6 +1411,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP 'receipt_date_time' => '', 'cancel_date' => '', 'cancel_date_time' => '', + 'hidden_Premium' => 1, ); if (!empty($params['id'])) { $existingContribution = civicrm_api3('contribution', 'getsingle', array( @@ -1432,6 +1433,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP CRM_Contribute_Form_AdditionalInfo::buildPremium($this); $this->submit(array_merge($defaults, $params), $action, CRM_Utils_Array::value('pledge_payment_id', $params)); + } /** diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 984d21c4f9..df93819b76 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -241,6 +241,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { */ public function testPremiumUpdate() { $form = new CRM_Contribute_Form_Contribution(); + $mut = new CiviMailUtils($this, TRUE); $form->testSubmit(array( 'total_amount' => 50, 'financial_type_id' => 1, @@ -251,9 +252,17 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'contribution_status_id' => 1, 'product_name' => array($this->products[0]['id'], 1), 'fulfilled_date' => '', + 'is_email_receipt' => TRUE, + 'from_email_address' => 'test@test.com', ), CRM_Core_Action::ADD); $contributionProduct = $this->callAPISuccess('contribution_product', 'getsingle', array()); $this->assertEquals('clumsy smurf', $contributionProduct['product_option']); + $mut->checkMailLog(array( + 'Premium Information', + 'Smurf', + 'clumsy smurf', + )); + $mut->stop(); } }