From: Seamus Lee Date: Thu, 11 Nov 2021 04:26:00 +0000 (+0000) Subject: [REF] Fix Pledge Test failing on php8 by ensuring all payments have a status assigned... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7ca0efd5a76bc87473dd6327784ea0169ae46ebf;p=civicrm-core.git [REF] Fix Pledge Test failing on php8 by ensuring all payments have a status assigned and that customGroup is always assigned to the template and updating test to pass in some additional form values --- diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index f20650fe4c..06412eda4c 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -534,6 +534,7 @@ GROUP BY currency [ 'amount' => $values['scheduled_amount'] ?? NULL, 'due_date' => $values['scheduled_date'] ?? NULL, + 'status' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'), ] ); @@ -570,10 +571,10 @@ GROUP BY currency } // handle custom data. + $customGroup = []; if (!empty($params['hidden_custom'])) { $groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', NULL, $params['id']); $pledgeParams = [['pledge_id', '=', $params['id'], 0, 0]]; - $customGroup = []; // retrieve custom data foreach ($groupTree as $groupID => $group) { $customFields = $customValues = []; @@ -590,8 +591,8 @@ GROUP BY currency $customGroup[$group['title']] = $customValues; } - $form->assign('customGroup', $customGroup); } + $form->assign('customGroup', $customGroup); // handle acknowledgment email stuff. [$pledgerDisplayName, $pledgerEmail] = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']); diff --git a/tests/phpunit/CRM/Pledge/Form/PledgeTest.php b/tests/phpunit/CRM/Pledge/Form/PledgeTest.php index 4759b9b2ad..4f3eecb3af 100644 --- a/tests/phpunit/CRM/Pledge/Form/PledgeTest.php +++ b/tests/phpunit/CRM/Pledge/Form/PledgeTest.php @@ -31,6 +31,13 @@ class CRM_Pledge_Form_PledgeTest extends CiviUnitTestCase { 'from_email_address' => Email::get() ->addWhere('contact_id', '=', $loggedInUser) ->addSelect('id')->execute()->first()['id'], + 'frequency_interval' => 1, + 'frequency_unit' => 'month', + 'installments' => 5, + 'currency' => 'USD', + 'scheduled_amount' => 10, + 'frequency_day' => 4, + 'status' => 'Pending', ]); $form->buildForm(); $form->postProcess();