carts() public method

public carts ( ) : Dumplie\Customer\Domain\Carts
return Dumplie\Customer\Domain\Carts
Example #1
0
 function test_removing_products_from_cart()
 {
     $cartId = $this->customerContext->createEmptyCart('EUR');
     $addCommand = new AddToCart('SKU_1', 2, (string) $cartId);
     $this->customerContext->commandBus()->handle($addCommand);
     $removeCommand = new RemoveFromCart((string) $cartId, 'SKU_1');
     $this->customerContext->commandBus()->handle($removeCommand);
     $this->clear();
     $cart = $this->customerContext->carts()->getById($cartId);
     $this->assertTrue($cart->isEmpty());
 }
Example #2
0
 function test_placing_new_order()
 {
     $cartId = $this->customerContext->createNewCartWithProducts('EUR', ['SKU_1', 'SKU_2']);
     $this->customerContext->checkout($cartId);
     $orderId = OrderId::generate();
     $placeOrderCommand = new PlaceOrder((string) $cartId, (string) $orderId);
     $this->customerContext->commandBus()->handle($placeOrderCommand);
     $this->clear();
     $this->assertFalse($this->customerContext->carts()->exists($cartId));
     $this->assertFalse($this->customerContext->checkouts()->existsForCart($cartId));
     $this->assertTrue($this->customerContext->orders()->exists($orderId));
 }