3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class CRM_Contribute_BAO_ProductTest
16 class CRM_Contribute_BAO_ProductTest
extends CiviUnitTestCase
{
21 public function testAdd() {
23 'name' => 'Test Product',
25 'imageOption' => 'noImage',
28 'min_contribution' => 5,
32 $product = CRM_Contribute_BAO_Product
::create($params);
33 $result = $this->assertDBNotNull('CRM_Contribute_BAO_Product', $product->id
,
35 'Database check on updated product record.'
38 $this->assertEquals($result, 'TP-10', 'Verify products sku.');
42 * Check method retrieve( )
44 public function testRetrieve() {
46 'name' => 'Test Product',
48 'imageOption' => 'noImage',
51 'min_contribution' => 5,
55 $product = CRM_Contribute_BAO_Product
::create($params);
56 $params = ['id' => $product->id
];
58 $result = CRM_Contribute_BAO_Product
::retrieve($params, $default);
59 $this->assertEquals(empty($result), FALSE, 'Verify products record.');
63 * Check method setIsActive( )
65 public function testSetIsActive() {
67 'name' => 'Test Product',
69 'imageOption' => 'noImage',
72 'min_contribution' => 5,
76 $product = CRM_Contribute_BAO_Product
::create($params);
77 CRM_Contribute_BAO_Product
::setIsActive($product->id
, 0);
79 $isActive = $this->assertDBNotNull('CRM_Contribute_BAO_Product', $product->id
,
81 'Database check on updated for product records is_active.'
84 $this->assertEquals($isActive, 0, 'Verify product records is_active.');
90 public function testDel() {
92 'name' => 'Test Product',
94 'imageOption' => 'noImage',
97 'min_contribution' => 5,
101 $product = CRM_Contribute_BAO_Product
::create($params);
102 CRM_Contribute_BAO_Product
::del($product->id
);
104 $params = ['id' => $product->id
];
106 $retrievedProduct = CRM_Contribute_BAO_Product
::retrieve($params, $defaults);
108 $this->assertEquals(empty($retrievedProduct), TRUE, 'Verify product record deletion.');