From 071e804af502b010442bb33b7e9c0382abd80b9c Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 24 Nov 2022 12:06:30 +1300 Subject: [PATCH] Test fix - setup is incongruent The point of this test is to check that line items are created. However, the test sloppily sets the value of the contribution to be different to the recurring contribution - which is something tested elsewhere but which is sloppy here. Fix --- tests/phpunit/api/v3/ContributionTest.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 547e7f472d..c91ea88c9e 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -2290,11 +2290,11 @@ class api_v3_ContributionTest extends CiviUnitTestCase { /** * Test repeat contribution successfully creates line item. * - * @throws \CRM_Core_Exception + * This is just testing a contribution which matches the recurring. */ public function testRepeatTransaction(): void { - $originalContribution = $this->setUpRepeatTransaction([], 'single'); - $this->callAPISuccess('contribution', 'repeattransaction', [ + $originalContribution = $this->setUpRepeatTransaction([], 'single', ['total_amount' => 500, 'net_amount' => 495]); + $this->callAPISuccess('Contribution', 'repeattransaction', [ 'original_contribution_id' => $originalContribution['id'], 'contribution_status_id' => 'Completed', 'trxn_id' => 4567, @@ -2314,7 +2314,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'price_field_id', ], ]; - $lineItem1 = $this->callAPISuccess('line_item', 'get', array_merge($lineItemParams, [ + $lineItem1 = $this->callAPISuccess('LineItem', 'get', array_merge($lineItemParams, [ 'entity_id' => $originalContribution['id'], ])); $lineItem2 = $this->callAPISuccess('line_item', 'get', array_merge($lineItemParams, [ @@ -2329,6 +2329,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'id' => $originalContribution['payment_processor_id'], 'return' => 'payment_instrument_id', ]), + 'total_amount' => 500, ], 'online'); } @@ -4420,7 +4421,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { */ protected function setUpRepeatTransaction(array $recurParams, $flag, array $contributionParams = []) { $paymentProcessorID = $this->paymentProcessorCreate(); - $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array_merge([ + $contributionRecur = $this->callAPISuccess('ContributionRecur', 'create', array_merge([ 'contact_id' => $this->_individualId, 'installments' => '12', 'frequency_interval' => '1', -- 2.25.1