3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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 +--------------------------------------------------------------------+
29 * Class CRM_Contribute_BAO_ProductTest
32 class CRM_Contribute_BAO_ProductTest
extends CiviUnitTestCase
{
34 public function setUp() {
41 public function testAdd() {
43 'name' => 'Test Product',
45 'imageOption' => 'noImage',
48 'min_contribution' => 5,
52 $product = CRM_Contribute_BAO_Product
::add($params);
54 $result = $this->assertDBNotNull('CRM_Contribute_BAO_Product', $product->id
,
56 'Database check on updated product record.'
59 $this->assertEquals($result, 'TP-10', 'Verify products sku.');
63 * Check method retrieve( )
65 public function testRetrieve() {
67 'name' => 'Test Product',
69 'imageOption' => 'noImage',
72 'min_contribution' => 5,
76 $product = CRM_Contribute_BAO_Product
::add($params);
77 $params = array('id' => $product->id
);
79 $result = CRM_Contribute_BAO_Product
::retrieve($params, $default);
80 $this->assertEquals(empty($result), FALSE, 'Verify products record.');
84 * Check method setIsActive( )
86 public function testSetIsActive() {
88 'name' => 'Test Product',
90 'imageOption' => 'noImage',
93 'min_contribution' => 5,
97 $product = CRM_Contribute_BAO_Product
::add($params);
98 CRM_Contribute_BAO_Product
::setIsActive($product->id
, 0);
100 $isActive = $this->assertDBNotNull('CRM_Contribute_BAO_Product', $product->id
,
102 'Database check on updated for product records is_active.'
105 $this->assertEquals($isActive, 0, 'Verify product records is_active.');
109 * Check method del( )
111 public function testDel() {
113 'name' => 'Test Product',
115 'imageOption' => 'noImage',
118 'min_contribution' => 5,
122 $product = CRM_Contribute_BAO_Product
::add($params);
124 CRM_Contribute_BAO_Product
::del($product->id
);
126 $params = array('id' => $product->id
);
128 $result = CRM_Contribute_BAO_Product
::retrieve($params, $defaults);
130 $this->assertEquals(empty($result), TRUE, 'Verify product record deletion.');