From 99af166d888510070cbad0031bc880b589b06063 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Mon, 16 Nov 2015 16:57:10 +0530 Subject: [PATCH] CRM-17578 fix - https://issues.civicrm.org/jira/browse/CRM-17578 --- CRM/Contribute/Form/AdditionalInfo.php | 2 +- CRM/Contribute/Form/Contribution.php | 2 +- tests/phpunit/WebTest/Contribute/UpdateContributionTest.php | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index 910772dcbf..bdf065da1c 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -195,7 +195,7 @@ class CRM_Contribute_Form_AdditionalInfo { */ public static function processPremium($params, $contributionID, $premiumID = NULL, $options = array()) { $selectedProductID = $params['product_name'][0]; - $selectedProductOptionID = $params['product_name'][1]; + $selectedProductOptionID = CRM_Utils_Array::value(1, $params['product_name']); $dao = new CRM_Contribute_DAO_ContributionProduct(); $dao->contribution_id = $contributionID; diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index b742655b09..e9d5bb8db2 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1701,7 +1701,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } - if ($contribution->id && !empty($formValues['product_name'][0])) { + if ($contribution->id && isset($formValues['product_name'][0])) { CRM_Contribute_Form_AdditionalInfo::processPremium($submittedValues, $contribution->id, $this->_premiumID, $this->_options ); diff --git a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php index fdef735f36..99f356ce4e 100755 --- a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php @@ -212,7 +212,6 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1"); // add premium $this->addPremium($premiumName, $sku, $amount, $price, $cost, $financialType['name']); - // add contribution with premium $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone"); @@ -245,7 +244,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { //Assertions $actualAmount = $this->_getPremiumActualCost($contId, $from, $to, NULL, "'civicrm_contribution'"); - $this->assertEquals($actualAmount, $cost, "Verify actual cost for deleted premium"); + $this->assertEquals($actualAmount, null, "Verify actual cost for deleted premium"); } public function testChangePaymentInstrument() { -- 2.25.1