function it_allows_to_remove_items() { $sku = new SKU("DUMPLIE_SKU_1"); $this->add(new Product($sku, Price::EUR(100), true), 1); $this->remove($sku); $this->isEmpty()->shouldReturn(true); }
function test_that_removes_product_from_stock() { $this->inventoryContext->commandBus()->handle(new CreateProduct('dumplie-sku-1', 20000, 'EUR', true)); $this->inventoryContext->commandBus()->handle(new RemoveProductFromStock('dumplie-sku-1')); $this->clear(); $product = $this->inventoryContext->products()->getBySku(new SKU('dumplie-sku-1')); $this->assertEquals(new Product(new SKU('dumplie-sku-1'), Price::fromInt(200, 'EUR'), false), $product); }
function it_can_be_used_to_place_order(Products $products, Carts $carts) { $product = new Product(new SKU("SKU"), Price::EUR(1000), true); $cart = new Cart(CartId::generate(), 'EUR'); $cart->add($product, 1); $carts->getById(Argument::type(CartId::class))->willReturn($cart); $products->getBySku(Argument::type(SKU::class))->willReturn($product); $order = $this->placeOrder(OrderId::generate(), $products, $carts); $order->shouldBeAnInstanceOf(Order::class); }
function setUp() { $this->eventLog = new InMemoryEventLog(); $this->transactionFactory = new Factory(); $this->customerContext = new InMemoryCustomerContext($this->eventLog, new TacticianFactory(), [new Product(new SKU('SKU_1'), Price::EUR(2500), true), new Product(new SKU('SKU_2'), Price::EUR(2500), true)]); }
function it_can_be_puting_back_to_stock() { $this->removeFromStock(); $this->putBackToStock(); $this->shouldBeLike(new Product(new SKU("DUMPLIE_SKU_1"), Price::fromInt(250, 'PLN'), $isInStock = true)); }
function test_if_can_be_created_through_static_constructor() { $price = Price::EUR(10000); $this->assertEquals(100.0, $price->floatValue()); $this->assertEquals('EUR', $price->currency()); }
public function test_that_put_back_product_with_given_sku_to_stock() { $this->putBackProductToStockHandler->handle(new PutBackProductToStock('dumplie_sku_1')); $product = $this->products->getBySku(new SKU('dumplie_sku_1')); $this->assertEquals(new Product(new SKU('dumplie_sku_1'), Price::fromInt(2000, 'EUR'), true), $product); }
public function test_that_remove_product_with_given_sku_from_stock() { $this->removeProductFromStockHandler->handle(new RemoveProductFromStock('dumplie_sku_1')); $product = $this->products->getBySku(new SKU('dumplie_sku_1')); $this->assertEquals(new Product(new SKU('dumplie_sku_1'), Price::fromInt(2000, 'EUR'), false), $product); }
function it_throws_exception_when_adding_to_price_with_a_different_precisions() { $this->beConstructedWith(10000, 'EUR', 100); $this->shouldThrow(DifferentPricePrecisionException::class)->during('add', [Price::EUR(100, 10)]); }
/** * @param Price $price * * @return bool */ public function hasSameCurrency(Price $price) : bool { return $price->currency() === $this->currency(); }