From 3d575ea69a27899527b22adb01989a13f2d5efbf Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 27 Jul 2016 21:01:46 +0530 Subject: [PATCH] CRM-16189, added test fixes ---------------------------------------- * CRM-16189: Improve support for Accrual Method bookkeeping https://issues.civicrm.org/jira/browse/CRM-16189 --- .../CRM/Financial/BAO/FinancialAccountTest.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php index 1a987f1e95..a6348191b3 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php @@ -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()); + } } } } -- 2.25.1