I wanna to test my entities created from doctrine, but i don`t know how to test id
if they are generated themself while object save to database.
class Dish
{
private ?int $id;
private Collection $prices;
public function __construct()
{
$this->prices = new ArrayCollection();
}
public function identifier(): string
{
return $this->id;
}
public function isEquals(Dish $dish): bool
{
return $this->identifier() === $dish->identifier();
}
public function addPrice(float $price)
{
$this->prices->add(new DishPrice($this, $price));
}
}
class DishPrice
{
use DeletedEntityTrait;
private ?int $id;
private float $price;
private Dish $dish;
public function __construct(Dish $dish, float $price)
{
$this->dish = $dish;
$this->price = $price;
}
public function identifier(): string
{
return $this->id;
}
public function isEquals(Dish $dish): bool
{
return $this->identifier() === $dish->identifier();
}
}
How to test isEquals
methods in both classes?
Aucun commentaire:
Enregistrer un commentaire