Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
6a488035 TO |
28 | |
29 | class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase { | |
30 | ||
31 | function get_info() { | |
32 | return array( | |
f17d75bb | 33 | 'name' => 'FinancialType BAOs', |
6a488035 | 34 | 'description' => 'Test all Contribute_BAO_Contribution methods.', |
f17d75bb | 35 | 'group' => 'CiviCRM BAO Tests', |
6a488035 TO |
36 | ); |
37 | } | |
38 | ||
39 | function setUp() { | |
40 | parent::setUp(); | |
41 | } | |
42 | ||
f17d75bb PN |
43 | function teardown() { |
44 | $this->financialAccountDelete('Donations'); | |
45 | } | |
46 | ||
6a488035 TO |
47 | /** |
48 | * check method add() | |
49 | */ | |
50 | function testAdd() { | |
51 | $params = array( | |
52 | 'name' => 'Donations', | |
53 | 'is_active' => 1, | |
54 | 'is_deductible' => 1, | |
55 | 'is_reserved' => 1, | |
56 | ); | |
57 | $ids = array(); | |
58 | $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
59 | $result = $this->assertDBNotNull( | |
60 | 'CRM_Financial_DAO_FinancialType', | |
61 | $financialType->id , | |
62 | 'name', | |
63 | 'id', | |
64 | 'Database check on added financial type record.' | |
65 | ); | |
66 | $this->assertEquals( $result, 'Donations', 'Verify Name for Financial Type'); | |
67 | } | |
68 | ||
69 | /** | |
70 | * check method retrive() | |
71 | */ | |
72 | function testRetrieve() { | |
73 | $params = array( | |
74 | 'name' => 'Donations', | |
75 | 'is_active' => 1, | |
76 | 'is_deductible' => 1, | |
77 | 'is_reserved' => 1, | |
78 | ); | |
79 | ||
80 | $ids = array(); | |
81 | CRM_Financial_BAO_FinancialType::add($params, $ids); | |
82 | ||
83 | $defaults = array(); | |
84 | $result = CRM_Financial_BAO_FinancialType::retrieve($params, $defaults); | |
f17d75bb | 85 | $this->assertEquals($result->name, 'Donations', 'Verify Name for Financial Type'); |
6a488035 TO |
86 | } |
87 | ||
88 | /** | |
89 | * check method setIsActive() | |
90 | */ | |
91 | function testSetIsActive() { | |
92 | $params = array( | |
f17d75bb | 93 | 'name' => 'Donations', |
6a488035 TO |
94 | 'is_deductible' => 0, |
95 | 'is_active' => 1, | |
96 | ); | |
97 | $ids = array(); | |
98 | $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
99 | $result = CRM_Financial_BAO_FinancialType::setIsActive($financialType->id, 0); | |
f17d75bb | 100 | $this->assertEquals($result, true , 'Verify financial type record updation for is_active.'); |
6a488035 TO |
101 | $isActive = $this->assertDBNotNull( |
102 | 'CRM_Financial_DAO_FinancialType', | |
103 | $financialType->id , | |
104 | 'is_active', | |
105 | 'id', | |
106 | 'Database check on updated for financial type is_active.' | |
107 | ); | |
f17d75bb | 108 | $this->assertEquals($isActive, 0, 'Verify financial types is_active.'); |
6a488035 TO |
109 | } |
110 | ||
111 | /** | |
112 | * check method del() | |
113 | */ | |
114 | function testDel() { | |
115 | $params = array( | |
f17d75bb | 116 | 'name' => 'Donations', |
6a488035 TO |
117 | 'is_deductible' => 0, |
118 | 'is_active' => 1, | |
119 | ); | |
120 | $ids = array(); | |
121 | $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
122 | ||
123 | CRM_Financial_BAO_FinancialType::del($financialType->id); | |
f17d75bb | 124 | $params = array('id' => $financialType->id); |
6a488035 | 125 | $result = CRM_Financial_BAO_FinancialType::retrieve($params, $defaults); |
f17d75bb | 126 | $this->assertEquals(empty($result), true, 'Verify financial types record deletion.'); |
6a488035 TO |
127 | } |
128 | } |