Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-mw committed Sep 9, 2021
1 parent a42ffde commit 792e65d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/MicroweberPackages/Shop/tests/CartTest.php
Expand Up @@ -9,13 +9,15 @@ class CartTest extends TestCase

public function testAddToCart()
{
app()->database_manager->extended_save_set_permission(true);

$params = array(
'title' => 'My new product',
'content_type' => 'product',
'subtype' => 'product',
'custom_fields' => array(
'custom_fields_advanced' => array(
array('type' => 'dropdown', 'name' => 'Color', 'value' => array('Purple', 'Blue')),
array('type' => 'price', 'name' => 'Price', 'value' => '9.99'),
array('type' => 'price', 'name' => 'Price', 'value' => '30'),

),
'is_active' => 1,);
Expand All @@ -29,13 +31,13 @@ public function testAddToCart()

$add_to_cart = array(
'content_id' => self::$content_id,
'price' => 35,
// 'price' => 30,
);
$cart_add = update_cart($add_to_cart);

$this->assertEquals(isset($cart_add['success']), true);
$this->assertEquals(isset($cart_add['product']), true);
$this->assertEquals($cart_add['product']['price'], 35);
$this->assertEquals($cart_add['product']['price'], 30);
}

public function testGetCart()
Expand All @@ -48,7 +50,7 @@ public function testGetCart()
);
$cart_add = update_cart($add_to_cart);
$cart_items = get_cart();

$this->assertEquals(isset($cart_add['success']), true);
$this->assertEquals(!empty($cart_items), true);
}
Expand All @@ -59,13 +61,13 @@ public function testSumCart()
$add_to_cart = array(
'content_id' => self::$content_id,
'qty' => 3,
'price' => 300,
'price' => 1300, // wrong price on purpose
);
$cart_add = update_cart($add_to_cart);
$cart_items = get_cart();

$sum = cart_sum();
$this->assertEquals($sum, 900);
$this->assertEquals($sum, 90);

$this->assertEquals(isset($cart_add['success']), true);
$this->assertEquals(!empty($cart_items), true);
Expand Down

0 comments on commit 792e65d

Please sign in to comment.