3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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';
31 * Class CRM_Contribute_BAO_ManagePremiumsTest
33 class CRM_Contribute_BAO_ManagePremiumsTest
extends CiviUnitTestCase
{
35 public function setUp() {
42 public function testAdd() {
45 'name' => 'Test Product',
47 'imageOption' => 'noImage',
50 'min_contribution' => 5,
54 $product = CRM_Contribute_BAO_ManagePremiums
::add($params, $ids);
56 $result = $this->assertDBNotNull('CRM_Contribute_BAO_ManagePremiums', $product->id
,
58 'Database check on updated product record.'
61 $this->assertEquals($result, 'TP-10', 'Verify products sku.');
65 * Check method retrieve( )
67 public function testRetrieve() {
70 'name' => 'Test Product',
72 'imageOption' => 'noImage',
75 'min_contribution' => 5,
79 $product = CRM_Contribute_BAO_ManagePremiums
::add($params, $ids);
80 $params = array('id' => $product->id
);
82 $result = CRM_Contribute_BAO_ManagePremiums
::retrieve($params, $default);
83 $this->assertEquals(empty($result), FALSE, 'Verify products record.');
87 * Check method setIsActive( )
89 public function testSetIsActive() {
92 'name' => 'Test Product',
94 'imageOption' => 'noImage',
97 'min_contribution' => 5,
101 $product = CRM_Contribute_BAO_ManagePremiums
::add($params, $ids);
102 CRM_Contribute_BAO_ManagePremiums
::setIsActive($product->id
, 0);
104 $isActive = $this->assertDBNotNull('CRM_Contribute_BAO_ManagePremiums', $product->id
,
106 'Database check on updated for product records is_active.'
109 $this->assertEquals($isActive, 0, 'Verify product records is_active.');
113 * Check method del( )
115 public function testDel() {
118 'name' => 'Test Product',
120 'imageOption' => 'noImage',
123 'min_contribution' => 5,
127 $product = CRM_Contribute_BAO_ManagePremiums
::add($params, $ids);
129 CRM_Contribute_BAO_ManagePremiums
::del($product->id
);
131 $params = array('id' => $product->id
);
133 $result = CRM_Contribute_BAO_ManagePremiums
::retrieve($params, $defaults);
135 $this->assertEquals(empty($result), TRUE, 'Verify product record deletion.');