CRM-16189-10 Added test for validateFinancialAccount
authorEdsel <edsel.lopez@jmaconsulting.biz>
Wed, 22 Jun 2016 10:23:50 +0000 (15:53 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Fri, 24 Jun 2016 14:35:49 +0000 (20:05 +0530)
Conflicts:

tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php

tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php

index 2d35858251f1c28f358be445fd117161edc9bc65..105d357d69d88efb30566b7cb659d678085a9b60 100644 (file)
@@ -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.");
+  }
+
 }