3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviUnitTestCase.php';
29 class CRM_Contribute_BAO_ManagePremiumsTest
extends CiviUnitTestCase
{
32 'name' => 'ManagePremiums BAOs',
33 'description' => 'Test all Contribute_BAO_Contribution methods.',
34 'group' => 'CiviCRM BAO Tests',
48 'name' => 'Test Product',
50 'imageOption' => 'noImage',
53 'min_contribution' => 5,
57 $product = CRM_Contribute_BAO_ManagePremiums
::add($params, $ids);
59 $result = $this->assertDBNotNull('CRM_Contribute_BAO_ManagePremiums', $product->id
,
61 'Database check on updated product record.'
64 $this->assertEquals($result, 'TP-10', 'Verify products sku.');
68 * check method retrieve( )
70 function testRetrieve() {
73 'name' => 'Test Product',
75 'imageOption' => 'noImage',
78 'min_contribution' => 5,
82 $product = CRM_Contribute_BAO_ManagePremiums
::add($params, $ids);
83 $params = array('id' => $product->id
);
85 $result = CRM_Contribute_BAO_ManagePremiums
::retrieve($params, $default);
86 $this->assertEquals(empty($result), FALSE, 'Verify products record.');
90 * check method setIsActive( )
92 function testSetIsActive() {
95 'name' => 'Test Product',
97 'imageOption' => 'noImage',
100 'min_contribution' => 5,
104 $product = CRM_Contribute_BAO_ManagePremiums
::add($params, $ids);
105 CRM_Contribute_BAO_ManagePremiums
::setIsActive($product->id
, 0);
107 $isActive = $this->assertDBNotNull('CRM_Contribute_BAO_ManagePremiums', $product->id
,
109 'Database check on updated for product records is_active.'
112 $this->assertEquals($isActive, 0, 'Verify product records is_active.');
116 * check method del( )
121 'name' => 'Test Product',
123 'imageOption' => 'noImage',
126 'min_contribution' => 5,
130 $product = CRM_Contribute_BAO_ManagePremiums
::add($params, $ids);
132 CRM_Contribute_BAO_ManagePremiums
::del($product->id
);
134 $params = array('id' => $product->id
);
136 $result = CRM_Contribute_BAO_ManagePremiums
::retrieve($params, $defaults);
138 $this->assertEquals(empty($result), TRUE, 'Verify product record deletion.');