Cart\Cart::clear PHP Method

clear() public method

Remove all items from the cart.
public clear ( )
    public function clear()
    {
        $this->items = array();
        $this->store->flush($this->id);
    }

Usage Example

Beispiel #1
0
 public function testClear()
 {
     $store = m::mock('Cart\\Storage\\Store');
     $store->shouldReceive('flush')->times(1);
     $cart = new Cart('foo', $store);
     $item1 = new CartItem(array('name' => 'foo'));
     $item2 = new CartItem(array('name' => 'bar'));
     $cart->add($item1);
     $cart->add($item2);
     $cart->clear();
     $cartItems = $cart->all();
     $this->assertTrue(count($cartItems) == 0);
 }