public function testConstruct() { $uuid = $this->getUuidMock(); $name = 'test product'; $price = new Money(10000); $category = new Category(new UuidIdentity('uuid2'), 'test cat'); $description = 'description'; $availability = true; $product = new Product($uuid, $name, $price, $category, $description, $availability, '/'); $this->assertSame($uuid, $product->getId()); $this->assertSame($name, $product->getName()); $this->assertSame($price, $product->getPrice()); $this->assertSame($category, $product->getCategory()); $this->assertSame($description, $product->getDescription()); $this->assertTrue($product->isAvailable()); }
/** * @param Product $product * @param Quantity $quantity * @return Order */ public function addProduct(Product $product, Quantity $quantity) : Order { if (!$product->isAvailable()) { throw new \RuntimeException(sprintf('Product #%s is not available', $product->getId())); } $lineItem = new LineItem($product, $this, $quantity); $this->lineItems->add($lineItem); return $this; }