From 4ecc6d4b9331ccad4754a8b31ec9612dc0168ce4 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Tue, 3 Dec 2013 18:26:28 +0530 Subject: [PATCH] --CRM-13310, fixed api test --- tests/phpunit/api/v3/ContributionTest.php | 35 +++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 767d7f7587..bdfcb3c92e 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -895,7 +895,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ); $contribution = $this->callAPISuccess('contribution', 'update', $newParams); $this->assertAPISuccess($contribution); - $this->_checkFinancialTrxn($contribution, 'paymentInstrument'); + $this->_checkFinancialTrxn($contribution, 'paymentInstrument', $instrumentId); } /* @@ -1444,7 +1444,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { } } - function _checkFinancialTrxn($contribution, $context) { + function _checkFinancialTrxn($contribution, $context, $instrumentId = NULL) { $trxnParams = array( 'entity_id' => $contribution['id'], 'entity_table' => 'civicrm_contribution', @@ -1460,12 +1460,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'from_financial_account_id' => CRM_Contribute_PseudoConstant::financialAccountType($contribution['financial_type_id'], $relationTypeId), ); } - elseif ($context == 'paymentInstrument') { - $compareParams = array( - 'from_financial_account_id' => 6, - 'to_financial_account_id' => 7, - ); - } elseif ($context == 'refund') { $compareParams = array( 'to_financial_account_id' => 6, @@ -1480,7 +1474,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'status_id' => 3, ); } - elseif ($context == 'changeFinancial') { + elseif ($context == 'changeFinancial' || $context == 'paymentInstrument') { $entityParams = array( 'entity_id' => $contribution['id'], 'entity_table' => 'civicrm_contribution', @@ -1491,16 +1485,27 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'id' => $trxn['financial_trxn_id'], ); $compareParams = array( - 'to_financial_account_id' => 12, 'total_amount' => -100, 'status_id' => 1, ); + if ($context == 'paymentInstrument') { + $compareParams += array( + 'to_financial_account_id' => CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount(4), + 'payment_instrument_id' => 4, + ); + } + else { + $compareParams['to_financial_account_id'] = 12; + } $this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $trxnParams1, $compareParams); - $compareParams = array( - 'to_financial_account_id' => 12, - 'total_amount' => 100, - 'status_id' => 1, - ); + $compareParams['total_amount'] = 100; + if ($context == 'paymentInstrument') { + $compareParams['to_financial_account_id'] = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($instrumentId); + $compareParams['payment_instrument_id'] = $instrumentId; + } + else { + $compareParams['to_financial_account_id'] = 12; + } } $this->assertDBCompareValues('CRM_Financial_DAO_FinancialTrxn', $params, $compareParams); -- 2.25.1