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 | ||
28 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
29 | class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase { | |
30 | function get_info() { | |
31 | return array( | |
32 | 'name' => 'FinancialAccount BAOs', | |
33 | 'description' => 'Test all Contribute_BAO_Contribution methods.', | |
34 | 'group' => 'CiviCRM BAO Tests', | |
35 | ); | |
36 | } | |
37 | ||
38 | function setUp() { | |
39 | parent::setUp(); | |
40 | } | |
41 | ||
42 | /** | |
43 | * check method add() | |
44 | */ | |
45 | function testAdd() { | |
46 | $params = array( | |
47 | 'name' => 'Donations', | |
48 | 'is_deductible' => 0, | |
49 | 'is_active' => 1, | |
50 | ); | |
51 | $ids = array(); | |
52 | $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
53 | ||
54 | $result = $this->assertDBNotNull('CRM_Financial_BAO_FinancialType', $contributionType->id, | |
55 | 'name', 'id', | |
56 | 'Database check on updated financial type record.' | |
57 | ); | |
58 | ||
59 | $this->assertEquals($result, 'Donations', 'Verify financial type name.'); | |
60 | } | |
61 | ||
62 | /** | |
63 | * check method retrive() | |
64 | */ | |
65 | function testRetrieve() { | |
66 | $params = array( | |
67 | 'name' => 'Donations', | |
68 | 'is_deductible' => 0, | |
69 | 'is_active' => 1, | |
70 | ); | |
71 | $ids = array(); | |
72 | $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
73 | ||
74 | $defaults = array(); | |
75 | $result = CRM_Financial_BAO_FinancialType::retrieve($params, $defaults); | |
76 | ||
77 | $this->assertEquals($result->name, 'Donations', 'Verify financial type name.'); | |
78 | } | |
79 | ||
80 | /** | |
81 | * check method setIsActive() | |
82 | */ | |
83 | function testSetIsActive() { | |
84 | $params = array( | |
85 | 'name' => 'testDonations', | |
86 | 'is_deductible' => 0, | |
87 | 'is_active' => 1, | |
88 | ); | |
89 | $ids = array(); | |
90 | $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
91 | $result = CRM_Financial_BAO_FinancialType::setIsActive($contributionType->id, 0); | |
92 | $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.'); | |
93 | ||
94 | $isActive = $this->assertDBNotNull('CRM_Financial_BAO_FinancialType', $contributionType->id, | |
95 | 'is_active', 'id', | |
96 | 'Database check on updated for financial type is_active.' | |
97 | ); | |
98 | $this->assertEquals($isActive, 0, 'Verify financial types is_active.'); | |
99 | } | |
100 | ||
101 | /** | |
102 | * check method del() | |
103 | */ | |
104 | function testdel() { | |
105 | $params = array( | |
106 | 'name' => 'checkDonations', | |
107 | 'is_deductible' => 0, | |
108 | 'is_active' => 1, | |
109 | ); | |
110 | $ids = array(); | |
111 | $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
112 | ||
113 | CRM_Financial_BAO_FinancialType::del($contributionType->id); | |
114 | $params = array('id' => $contributionType->id); | |
115 | $result = CRM_Financial_BAO_FinancialType::retrieve($params, $defaults); | |
116 | $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.'); | |
117 | } | |
118 | } | |
119 | ||
120 |