3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviUnitTestCase.php';
29 class CRM_Financial_BAO_FinancialAccountTest
extends CiviUnitTestCase
{
33 'name' => 'FinancialAccount BAOs',
34 'description' => 'Test all Contribute_BAO_Contribution methods.',
35 'group' => 'CiviCRM BAO Tests',
41 $this->organizationCreate();
45 $this->financialAccountDelete('Donations');
53 'name' => 'Donations',
58 $contributionType = CRM_Financial_BAO_FinancialAccount
::add($params, $ids);
60 $result = $this->assertDBNotNull(
61 'CRM_Financial_BAO_FinancialAccount',
62 $contributionType->id
,
65 'Database check on updated financial type record.'
68 $this->assertEquals($result, 'Donations', 'Verify financial type name.');
72 * check method retrive()
74 function testRetrieve() {
76 'name' => 'Donations',
80 $ids = $defaults = array();
81 $contributionType = CRM_Financial_BAO_FinancialAccount
::add($params, $ids);
83 $result = CRM_Financial_BAO_FinancialAccount
::retrieve($params, $defaults);
85 $this->assertEquals($result->name
, 'Donations', 'Verify financial type name.');
89 * check method setIsActive()
91 function testSetIsActive() {
93 'name' => 'Donations',
98 $contributionType = CRM_Financial_BAO_FinancialAccount
::add($params, $ids);
99 $result = CRM_Financial_BAO_FinancialAccount
::setIsActive($contributionType->id
, 0);
100 $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.');
102 $isActive = $this->assertDBNotNull(
103 'CRM_Financial_BAO_FinancialAccount',
104 $contributionType->id
,
107 'Database check on updated for financial type is_active.'
109 $this->assertEquals($isActive, 0, 'Verify financial types is_active.');
117 'name' => 'Donations',
118 'is_deductible' => 0,
122 $contributionType = CRM_Financial_BAO_FinancialAccount
::add($params, $ids);
124 CRM_Financial_BAO_FinancialAccount
::del($contributionType->id
);
125 $params = array('id' => $contributionType->id
);
126 $result = CRM_Financial_BAO_FinancialAccount
::retrieve($params, $defaults);
127 $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.');
131 * check method getAccountingCode()
133 function testGetAccountingCode() {
135 'name' => 'Donations',
141 $financialType = CRM_Financial_BAO_FinancialType
::add($params, $ids);
142 $financialAccountid = CRM_Core_DAO
::getFieldValue('CRM_Financial_DAO_FinancialAccount', 'Donations', 'id', 'name');
143 CRM_Core_DAO
::setFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccountid, 'accounting_code', '4800');
144 $accountingCode = CRM_Financial_BAO_FinancialAccount
::getAccountingCode($financialType->id
);
145 $this->assertEquals( $accountingCode, 4800, 'Verify accounting code.');