From: demeritcowboy Date: Thu, 30 Jul 2020 20:27:30 +0000 (-0400) Subject: notice on contribution edit X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=79528215f61b2be1bb317f525223cbd24f1b24de;p=civicrm-core.git notice on contribution edit --- diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 435c239813..cdf5b2f6a1 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -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; } diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index a1da2697a6..228e285dfd 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -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 diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 358a8bf486..bb5e440731 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -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']); + } + }