[REF] Fix Pledge Test failing on php8 by ensuring all payments have a status assigned...
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 11 Nov 2021 04:26:00 +0000 (04:26 +0000)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 12 Nov 2021 03:39:19 +0000 (14:39 +1100)
CRM/Pledge/BAO/Pledge.php
tests/phpunit/CRM/Pledge/Form/PledgeTest.php

index f20650fe4c3dc9a6332a447d0d090fbd35893ee1..06412eda4c018ee1ba348a2f6a20efcf20cc6ddb 100644 (file)
@@ -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']);
index 4759b9b2ad68299d42d51b03faf81071527d99a9..4f3eecb3af5ad50f4cedcca855d39e11ff8b765a 100644 (file)
@@ -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();