/** * clear cart * * @static */ public static function clear() { return \Darryldecode\Cart\Cart::clear(); }
public function test_clearing_cart() { $items = array(array('id' => 456, 'name' => 'Sample Item 1', 'price' => 67.98999999999999, 'quantity' => 3, 'attributes' => array()), array('id' => 568, 'name' => 'Sample Item 2', 'price' => 69.25, 'quantity' => 1, 'attributes' => array())); $this->cart->add($items); $this->assertFalse($this->cart->isEmpty(), 'prove first cart is not empty'); // now let's clear cart $this->cart->clear(); $this->assertTrue($this->cart->isEmpty(), 'cart should now be empty'); }
public function test_event_cart_clear() { $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')->once()->with(self::CART_INSTANCE_NAME . '.clearing', m::type('array')); $events->shouldReceive('fire')->once()->with(self::CART_INSTANCE_NAME . '.cleared', 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->clear(); }