From 7150b1c8765b9b4d90dfd35c14d02e673cd8f8a4 Mon Sep 17 00:00:00 2001 From: KarinG Date: Tue, 6 Sep 2016 12:08:38 -0600 Subject: [PATCH] Amended with fix for array(). --- CRM/Contribute/BAO/Contribution.php | 2 +- CRM/Contribute/BAO/ContributionRecur.php | 4 ++-- tests/phpunit/api/v3/ContributionTest.php | 11 +++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 0e5a92a09e..dcd1db91a5 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4578,7 +4578,7 @@ LIMIT 1;"; $contributionParams['id'] = $contribution->id; - // KG - if you update the contribution here with financial_type_id it can/will mess with $lineItem + // CRM-19309 - if you update the contribution here with financial_type_id it can/will mess with $lineItem // unsetting it here does NOT cause any other contribution test to fail! unset($contributionParams['financial_type_id']); $contributionResult = civicrm_api3('Contribution', 'create', $contributionParams); diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 25ac8cc43d..ea40fa3d74 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -902,7 +902,7 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) public static function calculateRecurLineItems($recurId, $total_amount, $financial_type_id) { $originalContributionID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $recurId, 'id', 'contribution_recur_id'); $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($originalContributionID); - $lineSets=[]; + $lineSets = array(); if (count($lineItems) == 1) { foreach ($lineItems as $index => $lineItem) { if ($financial_type_id) { @@ -921,7 +921,7 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) $lineSets[$priceField->price_set_id][] = $lineItem; } } - // KG if more than one then just pass them through: + // CRM-19309 if more than one then just pass them through: elseif (count($lineItems) > 1) { foreach ($lineItems as $index => $lineItem) { $lineSets[$index][] = $lineItem; diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 79063591d7..12bc23a3c0 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -1844,7 +1844,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { * Test repeat contribution successfully creates line items (plural). */ public function testRepeatTransactionLineItems() { - // KG + // CRM-19309 $originalContribution = $this->setUpRepeatTransaction($recurParams = array(), 'multiple'); $this->callAPISuccess('contribution', 'repeattransaction', array( 'original_contribution_id' => $originalContribution['id'], @@ -1883,9 +1883,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase { unset($lineItem2['values'][1]['id'], $lineItem2['values'][1]['entity_id']); $this->assertEquals($lineItem1['values'][1], $lineItem2['values'][1]); - // KG ok so we want to: - // check that financial_line_items have been created for entity_id 3 and 4; - visually they look good - // the first set of line items id 1 and 2 will not create financial_items b/c of how I created them + // CRM-19309 so in future we also want to: + // check that financial_line_items have been created for entity_id 3 and 4; $this->callAPISuccessGetCount('FinancialItem', array('description' => 'Sales Tax', 'amount' => 0), 0); $this->quickCleanUpFinancialEntities(); @@ -2956,9 +2955,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'payment_processor_id' => $paymentProcessorID, ), $recurParams)); - $originalContribution=[]; + $originalContribution = ''; if ($flag == 'multiple') { - // KG create a contribution + also add in line_items (plural): + // CRM-19309 create a contribution + also add in line_items (plural): $originalContribution = $this->callAPISuccess('contribution', 'create', array_merge( $this->_params, array( -- 2.25.1