From 77136dc6d4216211998729cea305d81868309809 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 24 Aug 2021 13:30:10 +1200 Subject: [PATCH] Re-fix test to work with new check 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 4918f332ee..29e34da7f6 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -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. -- 2.25.1