CRM-17578 fix - https://issues.civicrm.org/jira/browse/CRM-17578
authormonishdeb <monish.deb@webaccessglobal.com>
Mon, 16 Nov 2015 11:27:10 +0000 (16:57 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Mon, 16 Nov 2015 11:27:10 +0000 (16:57 +0530)
CRM/Contribute/Form/AdditionalInfo.php
CRM/Contribute/Form/Contribution.php
tests/phpunit/WebTest/Contribute/UpdateContributionTest.php

index 910772dcbf68c1d7f204979ffa289c8169ffbf05..bdf065da1c7a512809da88e2728f23c0a447a297 100644 (file)
@@ -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;
index b742655b0936176a8a335623686158793b08bbd5..e9d5bb8db2d5eaaf7b87cf040738a8475b04040f 100644 (file)
@@ -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
       );
index fdef735f3621e66a2ffc8243fd603d05360d412b..99f356ce4ec9d8c9a4750f288286caf2f830b9cd 100755 (executable)
@@ -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() {