CRM-16189, added test fixes
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 27 Jul 2016 15:31:46 +0000 (21:01 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Wed, 27 Jul 2016 15:31:46 +0000 (21:01 +0530)
----------------------------------------
* CRM-16189: Improve support for Accrual Method bookkeeping
  https://issues.civicrm.org/jira/browse/CRM-16189

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

index 1a987f1e954a2058b97a5d1a3dd19de293027d9a..a6348191b3e5d8d12d95d16eb961b8c428ef8cb8 100644 (file)
@@ -292,15 +292,21 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
    */
   public function testValidateFinancialType() {
     Civi::settings()->set('contribution_invoice_settings', array('deferred_revenue_enabled' => '1'));
-    $deferred = CRM_Financial_BAO_FinancialAccount::getDeferredFinancialType();
     $financialTypes = CRM_Contribute_PseudoConstant::financialType();
     foreach ($financialTypes as $key => $value) {
-      $validate = CRM_Financial_BAO_FinancialAccount::validateFinancialType($key);
-      if (array_key_exists($key, $deferred)) {
-        $this->assertFalse($validate, "This should not have thrown an error.");
+      try {
+        CRM_Financial_BAO_FinancialAccount::validateFinancialType($key);
+        if (!in_array($value, array('Member Dues', 'Event Fee'))) {
+          $this->fail("Missed expected exception");
+        }
       }
-      else {
-        $this->assertEquals($validate, TRUE);
+      catch (CRM_Core_Exception $e) {
+        if (in_array($value, array('Member Dues', 'Event Fees'))) {
+          $this->fail("Should not call exception");
+        }
+        else {
+          $this->assertEquals('Deferred revenue account is not configured for selected financial type. Please have an administrator set up the deferred revenue account at Administer > CiviContribute > Financial Accounts, then configure it for financial types at Administer > CiviContribution > Financial Types, Accounts', $e->getMessage());
+        }
       }
     }
   }