From 567ac630ca3e957f56ce178da8d18beab403b5d3 Mon Sep 17 00:00:00 2001 From: Edsel Date: Wed, 22 Jun 2016 15:53:50 +0530 Subject: [PATCH] CRM-16189-10 Added test for validateFinancialAccount Conflicts: tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php --- .../CRM/Financial/BAO/FinancialAccountTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php index 2d35858251..105d357d69 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php @@ -251,4 +251,19 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase { $this->assertTrue(array_key_exists($result, $financialTypes), "The financial type created does not have a deferred account relationship"); } + /** + * Test getting financial account for a given financial Type with a particular relationship. + */ + public function testValidateFinancialAccount() { + // Create a record with financial item having financial account as Event Fee. + $this->createParticipantWithContribution(); + $financialAccounts = CRM_Contribute_PseudoConstant::financialAccount(); + $financialAccountId = array_search('Event Fee', $financialAccounts); + $message = CRM_Financial_BAO_FinancialAccount::validateFinancialAccount($financialAccountId); + $this->assertTrue($message, "The financial account cannot be deleted. Failed asserting this was true."); + $financialAccountId = array_search('Member Dues', $financialAccounts); + $message = CRM_Financial_BAO_FinancialAccount::validateFinancialAccount($financialAccountId); + $this->assertFalse($message, "The financial account can be deleted. Failed asserting this was true."); + } + } -- 2.25.1