copyright and version fixes
[civicrm-core.git] / tests / phpunit / CRM / Contribute / BAO / ManagePremiumsTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
232624b1 4 | CiviCRM version 4.4 |
6a488035
TO
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
28require_once 'CiviTest/CiviUnitTestCase.php';
29class CRM_Contribute_BAO_ManagePremiumsTest extends CiviUnitTestCase {
30 function get_info() {
31 return array(
32 'name' => 'ManagePremiums 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 $ids = array();
47 $params = array(
48 'name' => 'Test Product',
49 'sku' => 'TP-10',
50 'imageOption' => 'noImage',
51 'price' => 12,
52 'cost' => 5,
53 'min_contribution' => 5,
54 'is_active' => 1,
55 );
56
57 $product = CRM_Contribute_BAO_ManagePremiums::add($params, $ids);
58
59 $result = $this->assertDBNotNull('CRM_Contribute_BAO_ManagePremiums', $product->id,
60 'sku', 'id',
61 'Database check on updated product record.'
62 );
63
64 $this->assertEquals($result, 'TP-10', 'Verify products sku.');
65 }
66
67 /**
68 * check method retrieve( )
69 */
70 function testRetrieve() {
71 $ids = array();
72 $params = array(
73 'name' => 'Test Product',
74 'sku' => 'TP-10',
75 'imageOption' => 'noImage',
76 'price' => 12,
77 'cost' => 5,
78 'min_contribution' => 5,
79 'is_active' => 1,
80 );
81
82 $product = CRM_Contribute_BAO_ManagePremiums::add($params, $ids);
83 $params = array('id' => $product->id);
84 $default = array();
85 $result = CRM_Contribute_BAO_ManagePremiums::retrieve($params, $default);
86 $this->assertEquals(empty($result), FALSE, 'Verify products record.');
87 }
88
89 /**
90 * check method setIsActive( )
91 */
92 function testSetIsActive() {
93 $ids = array();
94 $params = array(
95 'name' => 'Test Product',
96 'sku' => 'TP-10',
97 'imageOption' => 'noImage',
98 'price' => 12,
99 'cost' => 5,
100 'min_contribution' => 5,
101 'is_active' => 1,
102 );
103
104 $product = CRM_Contribute_BAO_ManagePremiums::add($params, $ids);
105 CRM_Contribute_BAO_ManagePremiums::setIsActive($product->id, 0);
106
107 $isActive = $this->assertDBNotNull('CRM_Contribute_BAO_ManagePremiums', $product->id,
108 'is_active', 'id',
109 'Database check on updated for product records is_active.'
110 );
111
112 $this->assertEquals($isActive, 0, 'Verify product records is_active.');
113 }
114
115 /**
116 * check method del( )
117 */
118 function testDel() {
119 $ids = array();
120 $params = array(
121 'name' => 'Test Product',
122 'sku' => 'TP-10',
123 'imageOption' => 'noImage',
124 'price' => 12,
125 'cost' => 5,
126 'min_contribution' => 5,
127 'is_active' => 1,
128 );
129
130 $product = CRM_Contribute_BAO_ManagePremiums::add($params, $ids);
131
132 CRM_Contribute_BAO_ManagePremiums::del($product->id);
133
134 $params = array('id' => $product->id);
135 $default = array();
136 $result = CRM_Contribute_BAO_ManagePremiums::retrieve($params, $defaults);
137
138 $this->assertEquals(empty($result), TRUE, 'Verify product record deletion.');
139 }
140}
141
142