public function test_event_cart_remove_item()
 {
     $events = m::mock('Illuminate\\Events\\Dispatcher');
     $events->shouldReceive('fire')->once()->with(self::CART_INSTANCE_NAME . '.created', m::type('array'));
     $events->shouldReceive('fire')->times(3)->with(self::CART_INSTANCE_NAME . '.adding', m::type('array'));
     $events->shouldReceive('fire')->times(3)->with(self::CART_INSTANCE_NAME . '.added', m::type('array'));
     $events->shouldReceive('fire')->times(1)->with(self::CART_INSTANCE_NAME . '.removing', m::type('array'));
     $events->shouldReceive('fire')->times(1)->with(self::CART_INSTANCE_NAME . '.removed', m::type('array'));
     $items = array(array('id' => 456, 'name' => 'Sample Item 1', 'price' => 67.98999999999999, 'quantity' => 4, 'attributes' => array()), array('id' => 568, 'name' => 'Sample Item 2', 'price' => 69.25, 'quantity' => 4, 'attributes' => array()), array('id' => 856, 'name' => 'Sample Item 3', 'price' => 50.25, 'quantity' => 4, 'attributes' => array()));
     $cart = new Cart(new SessionMock(), $events, self::CART_INSTANCE_NAME, 'SAMPLESESSIONKEY');
     $cart->add($items);
     $cart->remove(456);
 }
Exemple #2
0
 /**
  * removes an item on cart by item ID
  *
  * @param $id
  * @static 
  */
 public static function remove($id)
 {
     return \Darryldecode\Cart\Cart::remove($id);
 }
 public function test_cart_sub_total()
 {
     $items = array(array('id' => 456, 'name' => 'Sample Item 1', 'price' => 67.98999999999999, 'quantity' => 1, 'attributes' => array()), array('id' => 568, 'name' => 'Sample Item 2', 'price' => 69.25, 'quantity' => 1, 'attributes' => array()), array('id' => 856, 'name' => 'Sample Item 3', 'price' => 50.25, 'quantity' => 1, 'attributes' => array()));
     $this->cart->add($items);
     $this->assertEquals(187.49, $this->cart->getSubTotal(), 'Cart should have sub total of 187.49');
     // if we remove an item, the sub total should be updated as well
     $this->cart->remove(456);
     $this->assertEquals(119.5, $this->cart->getSubTotal(), 'Cart should have sub total of 119.5');
 }