Skip to content

Commit b43ee3d

Browse files
committed
tests for $item->getConditions();
1 parent 11eea71 commit b43ee3d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/ItemTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Darryldecode\Cart\Cart;
1010
use Mockery as m;
11+
use Darryldecode\Cart\CartCondition;
1112

1213
require_once __DIR__.'/helpers/SessionMock.php';
1314

@@ -55,4 +56,36 @@ public function test_item_get_sum_price_using_array_style()
5556

5657
$this->assertEquals(201.98, $item->getPriceSum(), 'Item summed price should be 201.98');
5758
}
59+
60+
public function test_item_get_conditions_empty()
61+
{
62+
$this->cart->add(455, 'Sample Item', 100.99, 2, array());
63+
64+
$item = $this->cart->get(455);
65+
66+
$this->assertEmpty($item->getConditions(), 'Item should have no conditions');
67+
}
68+
69+
public function test_item_get_conditions_with_conditions()
70+
{
71+
$itemCondition1 = new \Darryldecode\Cart\CartCondition(array(
72+
'name' => 'SALE 5%',
73+
'type' => 'sale',
74+
'target' => 'item',
75+
'value' => '-5%',
76+
));
77+
78+
$itemCondition2 = new CartCondition(array(
79+
'name' => 'Item Gift Pack 25.00',
80+
'type' => 'promo',
81+
'target' => 'item',
82+
'value' => '-25',
83+
));
84+
85+
$this->cart->add(455, 'Sample Item', 100.99, 2, array(),[$itemCondition1,$itemCondition2]);
86+
87+
$item = $this->cart->get(455);
88+
89+
$this->assertCount(2,$item->getConditions(), 'Item should have two conditions');
90+
}
5891
}

0 commit comments

Comments
 (0)