Skip to content

Commit

Permalink
Merge pull request #22037 from seamuslee001/ref_pledge_test_php8
Browse files Browse the repository at this point in the history
[REF] Fix Pledge Test failing on php8 by ensuring all payments have a…
  • Loading branch information
seamuslee001 authored Nov 11, 2021
2 parents 87c2938 + d1c4257 commit 06cc0f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CRM/Pledge/BAO/Pledge.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ public static function sendAcknowledgment(&$form, $params) {
[
'amount' => $values['scheduled_amount'] ?? NULL,
'due_date' => $values['scheduled_date'] ?? NULL,
'status' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'),
]
);

Expand Down Expand Up @@ -570,10 +571,10 @@ public static function sendAcknowledgment(&$form, $params) {
}

// 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 = [];
Expand All @@ -590,8 +591,8 @@ public static function sendAcknowledgment(&$form, $params) {
$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']);
Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/CRM/Pledge/Form/PledgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public function testPostProcess(): void {
'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();
Expand Down

0 comments on commit 06cc0f4

Please sign in to comment.