From 56a7794ddce10d22f3d120b18c10b490cc770151 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 14 Aug 2016 07:19:13 +1000 Subject: [PATCH] Add specific test of the getTaxRates function --- tests/phpunit/CRM/Core/PseudoConstantTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index cc5313b53a..4467d0ef53 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -1090,4 +1090,34 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { $this->assertEquals(array_flip($byId), $result); } + public function testGetTaxRates() { + $contact = $this->createLoggedInUser(); + $financialType = $this->callAPISuccess('financial_type', 'create', array( + 'name' => 'Test taxable financial Type', + 'is_reserved' => 0, + 'is_active' => 1, + )); + $financialAccount = $this->callAPISuccess('financial_account', 'create', array( + 'name' => 'Test Tax financial account ', + 'contact_id' => $contact, + 'financial_account_type_id' => 2, + 'is_tax' => 1, + 'tax_rate' => 5.00, + 'is_reserved' => 0, + 'is_active' => 1, + 'is_default' => 0, + )); + $financialTypeId = $financialType['id']; + $financialAccountId = $financialAccount['id']; + $financialAccountParams = array( + 'entity_table' => 'civicrm_financial_type', + 'entity_id' => $financialTypeId, + 'account_relationship' => 10, + 'financial_account_id' => $financialAccountId, + ); + CRM_Financial_BAO_FinancialTypeAccount::add($financialAccountParams); + $taxRates = CRM_Core_PseudoConstant::getTaxRates(); + $this->assertEquals('5.00', $taxRates[$financialType['id']]); + } + } -- 2.25.1