From: Pradeep Nayak Date: Tue, 3 Jan 2017 13:32:52 +0000 (+0530) Subject: CRM-19585, added test for getSalesTaxFinancialAccounts() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=adbc354b34d012b82bd87998438eac76e5b72ad1;p=civicrm-core.git CRM-19585, added test for getSalesTaxFinancialAccounts() ---------------------------------------- * CRM-19585: Sales tax issue https://issues.civicrm.org/jira/browse/CRM-19585 --- diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index d2f13ef415..c2b0545f5a 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -1069,4 +1069,19 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; $this->assertEquals($financialTrxn['total_amount'], 8000, 'Invalid Tax amount.'); } + /** + * Test for function getSalesTaxFinancialAccounts(). + */ + public function testgetSalesTaxFinancialAccounts() { + $this->enableTaxAndInvoicing(); + $financialType = $this->createFinancialType(); + $financialAccount = $this->relationForFinancialTypeWithFinancialAccount($financialType['id']); + $expectedResult = array($financialAccount->financial_account_id => $financialAccount->financial_account_id); + $financialType = $this->createFinancialType(); + $financialAccount = $this->relationForFinancialTypeWithFinancialAccount($financialType['id']); + $expectedResult[$financialAccount->financial_account_id] = $financialAccount->financial_account_id; + $salesTaxFinancialAccount = CRM_Contribute_BAO_Contribution::getSalesTaxFinancialAccounts(); + $this->assertTrue(($salesTaxFinancialAccount == $expectedResult), 'Function returned wrong values.'); + } + } diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 296dc5ec7d..c4aba681ee 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -3629,6 +3629,23 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) } } + /** + * Create Financial Type. + * + * @param array $params + * + * @return array + */ + protected function createFinancialType($params = array()) { + $params = array_merge($params, + array( + 'name' => 'Financial-Type -' . substr(sha1(rand()), 0, 7), + 'is_active' => 1, + ) + ); + return $this->callAPISuccess('FinancialType', 'create', $params); + } + /** * Enable Tax and Invoicing */