diff --git a/src/entity/order/Order.php b/src/entity/order/Order.php new file mode 100644 index 0000000..422e361 --- /dev/null +++ b/src/entity/order/Order.php @@ -0,0 +1,89 @@ +products = new ArrayCollection(); + } + + public function removeProduct(ProductInterface $product): void + { + $this->products->remove($product->getId()); + } + + public function addProduct(ProductInterface $product): void + { + $this->products->set($product->getId(), $product); + } + + public function getId(): int + { + return $this->id; + } + + public function getProducts(): ArrayCollection + { + return $this->products; + } + + public function getStatus(): bool + { + return $this->status; + } + + public function setCustomer(UserInterface $customer) + { + $this->customer = $customer; + } + + public function setStatus(bool $status): void + { + $this->status = $status; + } + + public function getCustomer(): UserInterface + { + return $this->customer; + } + + public function setId(int $id): void + { + $this->id = $id; + } + +} + diff --git a/src/entity/order/OrderInterface.php b/src/entity/order/OrderInterface.php index 92f572f..5090241 100644 --- a/src/entity/order/OrderInterface.php +++ b/src/entity/order/OrderInterface.php @@ -40,6 +40,8 @@ interface OrderInterface */ public function getId():int; + public function setId(int $id):void; + /** * @return UserInterface */ @@ -48,7 +50,7 @@ interface OrderInterface /** * @param UserInterface $customer */ - public function setCutomer(UserInterface $customer); + public function setCustomer(UserInterface $customer); /** * @param bool $status diff --git a/src/entity/order/OrderTest.php b/src/entity/order/OrderTest.php new file mode 100644 index 0000000..8c5d2af --- /dev/null +++ b/src/entity/order/OrderTest.php @@ -0,0 +1,67 @@ +order = new Order(); + $this->customer = new User(); + $this->product = new Product(); + $this->product->setId(1234); + $this->order->setId('123456'); + $this->order->setCustomer($this->customer); + $this->order->setStatus(true); + $this->order->addProduct($this->product); + } + + public function testId():void{ + $this->assertEquals(self::ID, $this->order->getId()); + } + + public function testCustomer():void{ + $this->assertEquals($this->customer, $this->order->getCustomer()); + } + + public function testStatus():void{ + $this->assertEquals(true, $this->order->getStatus()); + } + + public function testAdd():void{ + $this->assertEquals($this->product, $this->order->getProducts()->get($this->product->getId())); + } + + public function testRemove():void{ + $this->order->removeProduct($this->product); + $this->assertEquals(false, $this->order->getProducts()->contains($this->product)); + } +} + diff --git a/src/entity/product/ProductInterface.php b/src/entity/product/ProductInterface.php index 2beb421..9367d40 100644 --- a/src/entity/product/ProductInterface.php +++ b/src/entity/product/ProductInterface.php @@ -3,7 +3,6 @@ namespace entity\product; use entity\price\PriceInterface; use entity\image\ImageInterface; -use entity\color\ColorInterface; /** * Attention: