CRM-16189, fixed test
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 27 Jul 2016 13:08:51 +0000 (18:38 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Wed, 27 Jul 2016 13:08:51 +0000 (18:38 +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 f44e1aae583aa1b5b46212b1a33ad2094450a97f..7e228595462e5fe4449f1bf9223ee325af8e068e 100644 (file)
@@ -280,8 +280,12 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
         ),
       ),
     );
-    $valid = CRM_Financial_BAO_FinancialAccount::checkFinancialTypeHasDeferred($params);
-    $this->assertFalse($valid, "This should have been false");
+    try {
+      CRM_Financial_BAO_FinancialAccount::checkFinancialTypeHasDeferred($params);
+    }
+    catch (CRM_Core_Exception $e) {
+      $this->fail("Missed expected exception");
+    }
     $params = array(
       'contact_id' => $cid,
       'receive_date' => '2016-01-20',
@@ -289,8 +293,13 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
       'financial_type_id' => 1,
       'revenue_recognition_date' => date('Ymd', strtotime("+1 month")),
     );
-    $valid = CRM_Financial_BAO_FinancialAccount::checkFinancialTypeHasDeferred($params);
-    $this->assertTrue($valid, "This should have been true.");
+    try {
+      CRM_Financial_BAO_FinancialAccount::checkFinancialTypeHasDeferred($params);
+      $this->fail("Missed expected exception");
+    }
+    catch (CRM_Core_Exception $e) {
+      $this->assertEquals('Revenue recognition date can only be specified if the financial type selected has a deferred revenue account configured. 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());
+    }
   }
 
   /**