notice on contribution edit
authordemeritcowboy <demeritcowboy@hotmail.com>
Thu, 30 Jul 2020 20:27:30 +0000 (16:27 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Thu, 30 Jul 2020 20:27:30 +0000 (16:27 -0400)
CRM/Contribute/Form/AbstractEditPayment.php
CRM/Contribute/Form/Contribution/Confirm.php
tests/phpunit/CRM/Contribute/Form/ContributionTest.php

index 435c2398139c5005500f97b51c2df4de5616b3e6..cdf5b2f6a1e95ead61d4e2096086438533373826 100644 (file)
@@ -718,7 +718,7 @@ WHERE  contribution_id = {$id}
       $title .= " - {$info['title']}";
     }
     $this->assign('transaction', TRUE);
-    $this->assign('payments', $paymentInfo['transaction']);
+    $this->assign('payments', $paymentInfo['transaction'] ?? NULL);
     $this->assign('paymentLinks', $paymentInfo['payment_links']);
     return $title;
   }
index a1da2697a6227557b62ff44418b486bc9b836acf..228e285dfdee18ffeef735d6bf931e6d444bc852 100644 (file)
@@ -954,7 +954,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         }
         $smarty = CRM_Core_Smarty::singleton();
         $smarty->assign('dataArray', $dataArray);
-        $smarty->assign('totalTaxAmount', $params['tax_amount']);
+        $smarty->assign('totalTaxAmount', $params['tax_amount'] ?? NULL);
       }
 
       // lets store it in the form variable so postProcess hook can get to this and use it
index 358a8bf4867e12b6104701aabdd10736f8a0246c..bb5e440731bf5b0c9cd2048e7dbbce6b373aa5b0 100644 (file)
@@ -1696,4 +1696,29 @@ Price Field - Price Field 1        1   $ 100.00      $ 100.00
     $this->membershipDelete($membership['id']);
   }
 
+  /**
+   * Test no warnings or errors during preProcess when editing.
+   */
+  public function testPreProcessContributionEdit() {
+    // Simulate a contribution in pending status
+    $contribution = $this->callAPISuccess(
+      'Contribution',
+      'create',
+      array_merge($this->_params, ['contribution_status_id' => 'Pending'])
+    );
+
+    // set up the form to edit the contribution and call preProcess
+    $form = $this->getFormObject('CRM_Contribute_Form_Contribution');
+    $_REQUEST['cid'] = $this->_individualId;
+    $_REQUEST['id'] = $contribution['id'];
+    $form->_action = CRM_Core_Action::UPDATE;
+    $form->preProcess();
+
+    // Check something while we're here
+    $this->assertEquals($contribution['id'], $form->_values['contribution_id']);
+
+    unset($_REQUEST['cid']);
+    unset($_REQUEST['id']);
+  }
+
 }