Merge pull request #4627 from colemanw/docblocks
[civicrm-core.git] / tests / phpunit / CRM / Contribute / BAO / ManagePremiumsTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06a1bc01 4 | CiviCRM version 4.5 |
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 +--------------------------------------------------------------------+
26*/
27
28require_once 'CiviTest/CiviUnitTestCase.php';
e9479dcf
EM
29
30/**
31 * Class CRM_Contribute_BAO_ManagePremiumsTest
32 */
6a488035 33class CRM_Contribute_BAO_ManagePremiumsTest extends CiviUnitTestCase {
e9479dcf
EM
34 /**
35 * @return array
36 */
6a488035
TO
37 function get_info() {
38 return array(
39 'name' => 'ManagePremiums BAOs',
40 'description' => 'Test all Contribute_BAO_Contribution methods.',
41 'group' => 'CiviCRM BAO Tests',
42 );
43 }
44
45 function setUp() {
46 parent::setUp();
47 }
48
49 /**
50 * check method add()
51 */
52 function testAdd() {
53 $ids = array();
54 $params = array(
55 'name' => 'Test Product',
56 'sku' => 'TP-10',
57 'imageOption' => 'noImage',
58 'price' => 12,
59 'cost' => 5,
60 'min_contribution' => 5,
61 'is_active' => 1,
62 );
63
64 $product = CRM_Contribute_BAO_ManagePremiums::add($params, $ids);
65
66 $result = $this->assertDBNotNull('CRM_Contribute_BAO_ManagePremiums', $product->id,
67 'sku', 'id',
68 'Database check on updated product record.'
69 );
70
71 $this->assertEquals($result, 'TP-10', 'Verify products sku.');
72 }
73
74 /**
75 * check method retrieve( )
76 */
77 function testRetrieve() {
78 $ids = array();
79 $params = array(
80 'name' => 'Test Product',
81 'sku' => 'TP-10',
82 'imageOption' => 'noImage',
83 'price' => 12,
84 'cost' => 5,
85 'min_contribution' => 5,
86 'is_active' => 1,
87 );
88
89 $product = CRM_Contribute_BAO_ManagePremiums::add($params, $ids);
90 $params = array('id' => $product->id);
91 $default = array();
92 $result = CRM_Contribute_BAO_ManagePremiums::retrieve($params, $default);
93 $this->assertEquals(empty($result), FALSE, 'Verify products record.');
94 }
95
96 /**
97 * check method setIsActive( )
98 */
99 function testSetIsActive() {
100 $ids = array();
101 $params = array(
102 'name' => 'Test Product',
103 'sku' => 'TP-10',
104 'imageOption' => 'noImage',
105 'price' => 12,
106 'cost' => 5,
107 'min_contribution' => 5,
108 'is_active' => 1,
109 );
110
111 $product = CRM_Contribute_BAO_ManagePremiums::add($params, $ids);
112 CRM_Contribute_BAO_ManagePremiums::setIsActive($product->id, 0);
113
114 $isActive = $this->assertDBNotNull('CRM_Contribute_BAO_ManagePremiums', $product->id,
115 'is_active', 'id',
116 'Database check on updated for product records is_active.'
117 );
118
119 $this->assertEquals($isActive, 0, 'Verify product records is_active.');
120 }
121
122 /**
123 * check method del( )
124 */
125 function testDel() {
126 $ids = array();
127 $params = array(
128 'name' => 'Test Product',
129 'sku' => 'TP-10',
130 'imageOption' => 'noImage',
131 'price' => 12,
132 'cost' => 5,
133 'min_contribution' => 5,
134 'is_active' => 1,
135 );
136
137 $product = CRM_Contribute_BAO_ManagePremiums::add($params, $ids);
138
139 CRM_Contribute_BAO_ManagePremiums::del($product->id);
140
141 $params = array('id' => $product->id);
142 $default = array();
143 $result = CRM_Contribute_BAO_ManagePremiums::retrieve($params, $defaults);
144
145 $this->assertEquals(empty($result), TRUE, 'Verify product record deletion.');
146 }
147}
148
149