From 36937e7b2033bb8a5688ba40308576b9bb25e0c7 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 27 Jul 2016 18:38:51 +0530 Subject: [PATCH] CRM-16189, fixed test ---------------------------------------- * CRM-16189: Improve support for Accrual Method bookkeeping https://issues.civicrm.org/jira/browse/CRM-16189 --- .../CRM/Financial/BAO/FinancialAccountTest.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php index f44e1aae58..7e22859546 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php @@ -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()); + } } /** -- 2.25.1