mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2024-11-22 10:11:04 +01:00
Solved add bug
This commit is contained in:
parent
ca8aaa95be
commit
9f059d1202
@ -42,12 +42,17 @@ final class Order implements OrderInterface
|
|||||||
|
|
||||||
public function removeProduct(ProductInterface $product): void
|
public function removeProduct(ProductInterface $product): void
|
||||||
{
|
{
|
||||||
$this->products->remove($product->getId());
|
foreach ($this->products->toArray() as $productItem){
|
||||||
|
if($productItem->getId() ===
|
||||||
|
$product->getId()){
|
||||||
|
$this->products->removeElement($productItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addProduct(ProductInterface $product): void
|
public function addProduct(ProductInterface $product): void
|
||||||
{
|
{
|
||||||
$this->products->set($product->getId(), $product);
|
$this->products->add($product);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): int
|
public function getId(): int
|
||||||
|
@ -56,7 +56,7 @@ class OrderTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testAdd():void{
|
public function testAdd():void{
|
||||||
$this->assertEquals($this->product, $this->order->getProducts()->get($this->product->getId()));
|
$this->assertEquals(true, $this->order->getProducts()->contains($this->product));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemove():void{
|
public function testRemove():void{
|
||||||
|
Loading…
Reference in New Issue
Block a user