Re-fix test to work with new check
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 24 Aug 2021 01:30:10 +0000 (13:30 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 24 Aug 2021 01:40:41 +0000 (13:40 +1200)
A new check was enabled for this test recently and it passed because we
were doing recalculation - but that recalculation was not always right
and there is no expectation that passing in the wrong total_amount
is OK so this fixes total_amount to be equal to the
sum of the line items - which is what is checked

tests/phpunit/api/v3/ContributionTest.php

index 4918f332eeeef5f5af0a010e4ad03c1bcd487048..29e34da7f6750ae22cee4d9c8a7abb0682a63674 100644 (file)
@@ -3586,6 +3586,21 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     //Update it to Failed.
     $form->_params['id'] = $contribution['id'];
     $form->_params['contribution_status_id'] = 4;
+    // We now have 2 line items of $20 each.
+    // form params['total_amount'] is set to $20 but
+    // now that we have 2 line items of $20 it should be $40
+    // this is an artificial test scenario.
+    // but we need to ensure it is valid enough to
+    // pass validation checks. Note the way these lines are created
+    // above is wrong wrong wrong - but the rc is not the place to fix.
+    // Also note that this test has historically created incorrect
+    // financial data. The financials check was enabled on it
+    // AFTER the code we are honing was merged.
+    // so it used to tolerate incorrect financials, then it started
+    // re-calculating them (correctly in this artificial scenario - but not for tax scenarios)
+    // but as of 5.41 it is 'accepting' the total_amount
+    // so we should pass in a correct one.
+    $form->_params['total_amount'] = 40;
 
     $form->testSubmit($form->_params, CRM_Core_Action::UPDATE);
     //Existing membership should not get updated to expired.