public function test_adding_a_default_inventory_to_cart_then_removing_it() { $repository = new CartRepository(); $product = Factory::create(new Product()); $inventory = Factory::create(new Inventory(), ['product_id' => $product->id, 'quantity' => 5]); $this->assertFalse($repository->getCart()->exists()); $repository->addToCart($product->id, [], 1); $this->assertTrue($repository->getCart()->exists()); $this->assertEquals(1, $repository->getCart()->items()->count()); $item = $repository->getItems()->first(); $repository->removeFromCart($item->id); $this->assertEquals(0, $repository->getCart()->items()->count()); }
/** * Remove an item from the cart * * @return void */ public function onRemoveFromCart() { $itemId = input('id'); $this->repository->removeFromCart($itemId); }