Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
e9479dcf EM |
29 | |
30 | /** | |
31 | * Class CRM_Contribute_BAO_ContributionTypeTest | |
32 | */ | |
6a488035 | 33 | class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase { |
6a488035 | 34 | |
00be9182 | 35 | public function setUp() { |
6a488035 | 36 | parent::setUp(); |
f17d75bb PN |
37 | $this->organizationCreate(); |
38 | } | |
e9479dcf | 39 | |
00be9182 | 40 | public function teardown() { |
f17d75bb | 41 | $this->financialAccountDelete('Donations'); |
6a488035 TO |
42 | } |
43 | ||
44 | /** | |
100fef9d | 45 | * Check method add() |
6a488035 | 46 | */ |
00be9182 | 47 | public function testAdd() { |
6a488035 TO |
48 | $params = array( |
49 | 'name' => 'Donations', | |
50 | 'is_deductible' => 0, | |
51 | 'is_active' => 1, | |
52 | ); | |
53 | $ids = array(); | |
54 | $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
55 | ||
56 | $result = $this->assertDBNotNull('CRM_Financial_BAO_FinancialType', $contributionType->id, | |
57 | 'name', 'id', | |
58 | 'Database check on updated financial type record.' | |
59 | ); | |
60 | ||
61 | $this->assertEquals($result, 'Donations', 'Verify financial type name.'); | |
62 | } | |
63 | ||
64 | /** | |
100fef9d | 65 | * Check method retrive() |
6a488035 | 66 | */ |
00be9182 | 67 | public function testRetrieve() { |
6a488035 TO |
68 | $params = array( |
69 | 'name' => 'Donations', | |
70 | 'is_deductible' => 0, | |
71 | 'is_active' => 1, | |
72 | ); | |
73 | $ids = array(); | |
74 | $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
75 | ||
76 | $defaults = array(); | |
77 | $result = CRM_Financial_BAO_FinancialType::retrieve($params, $defaults); | |
78 | ||
79 | $this->assertEquals($result->name, 'Donations', 'Verify financial type name.'); | |
80 | } | |
81 | ||
82 | /** | |
100fef9d | 83 | * Check method setIsActive() |
6a488035 | 84 | */ |
00be9182 | 85 | public function testSetIsActive() { |
6a488035 | 86 | $params = array( |
f17d75bb | 87 | 'name' => 'Donations', |
6a488035 TO |
88 | 'is_deductible' => 0, |
89 | 'is_active' => 1, | |
90 | ); | |
92915c55 | 91 | $ids = array(); |
6a488035 | 92 | $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); |
92915c55 | 93 | $result = CRM_Financial_BAO_FinancialType::setIsActive($contributionType->id, 0); |
6a488035 TO |
94 | $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.'); |
95 | ||
96 | $isActive = $this->assertDBNotNull('CRM_Financial_BAO_FinancialType', $contributionType->id, | |
97 | 'is_active', 'id', | |
98 | 'Database check on updated for financial type is_active.' | |
99 | ); | |
100 | $this->assertEquals($isActive, 0, 'Verify financial types is_active.'); | |
101 | } | |
102 | ||
103 | /** | |
100fef9d | 104 | * Check method del() |
6a488035 | 105 | */ |
00be9182 | 106 | public function testdel() { |
6a488035 | 107 | $params = array( |
f17d75bb | 108 | 'name' => 'Donations', |
6a488035 TO |
109 | 'is_deductible' => 0, |
110 | 'is_active' => 1, | |
111 | ); | |
112 | $ids = array(); | |
113 | $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); | |
114 | ||
115 | CRM_Financial_BAO_FinancialType::del($contributionType->id); | |
116 | $params = array('id' => $contributionType->id); | |
117 | $result = CRM_Financial_BAO_FinancialType::retrieve($params, $defaults); | |
118 | $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.'); | |
119 | } | |
96025800 | 120 | |
6a488035 | 121 | } |