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';
30 * Class CRM_Financial_BAO_FinancialAccountTest
32 class CRM_Financial_BAO_FinancialAccountTest
extends CiviUnitTestCase
{
39 'name' => 'FinancialAccount BAOs',
40 'description' => 'Test all Contribute_BAO_Contribution methods.',
41 'group' => 'CiviCRM BAO Tests',
47 $this->organizationCreate();
51 $this->financialAccountDelete('Donations');
59 'name' => 'Donations',
64 $contributionType = CRM_Financial_BAO_FinancialAccount
::add($params, $ids);
66 $result = $this->assertDBNotNull(
67 'CRM_Financial_BAO_FinancialAccount',
68 $contributionType->id
,
71 'Database check on updated financial type record.'
74 $this->assertEquals($result, 'Donations', 'Verify financial type name.');
78 * check method retrive()
80 function testRetrieve() {
82 'name' => 'Donations',
86 $ids = $defaults = array();
87 $contributionType = CRM_Financial_BAO_FinancialAccount
::add($params, $ids);
89 $result = CRM_Financial_BAO_FinancialAccount
::retrieve($params, $defaults);
91 $this->assertEquals($result->name
, 'Donations', 'Verify financial type name.');
95 * check method setIsActive()
97 function testSetIsActive() {
99 'name' => 'Donations',
100 'is_deductible' => 0,
104 $contributionType = CRM_Financial_BAO_FinancialAccount
::add($params, $ids);
105 $result = CRM_Financial_BAO_FinancialAccount
::setIsActive($contributionType->id
, 0);
106 $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.');
108 $isActive = $this->assertDBNotNull(
109 'CRM_Financial_BAO_FinancialAccount',
110 $contributionType->id
,
113 'Database check on updated for financial type is_active.'
115 $this->assertEquals($isActive, 0, 'Verify financial types is_active.');
123 'name' => 'Donations',
124 'is_deductible' => 0,
128 $contributionType = CRM_Financial_BAO_FinancialAccount
::add($params, $ids);
130 CRM_Financial_BAO_FinancialAccount
::del($contributionType->id
);
131 $params = array('id' => $contributionType->id
);
132 $result = CRM_Financial_BAO_FinancialAccount
::retrieve($params, $defaults);
133 $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.');
137 * check method getAccountingCode()
139 function testGetAccountingCode() {
141 'name' => 'Donations',
147 $financialType = CRM_Financial_BAO_FinancialType
::add($params, $ids);
148 $financialAccountid = CRM_Core_DAO
::getFieldValue('CRM_Financial_DAO_FinancialAccount', 'Donations', 'id', 'name');
149 CRM_Core_DAO
::setFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccountid, 'accounting_code', '4800');
150 $accountingCode = CRM_Financial_BAO_FinancialAccount
::getAccountingCode($financialType->id
);
151 $this->assertEquals( $accountingCode, 4800, 'Verify accounting code.');