Solved add bug

This commit is contained in:
Kevin Frantz committed 2018-07-15 13:07:26 +02:00
1 parent ca8aaa95be
commit 9f059d1202
2 files changed
+8 -3

No files matched your search

+7 -2
View File
@@ -42,12 +42,17 @@ final class Order implements OrderInterface
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
{
$this->products->set($product->getId(), $product);
$this->products->add($product);
}
public function getId(): int
+1 -1
View File
@@ -56,7 +56,7 @@ class OrderTest extends TestCase
}
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{