test(sync) : extend factories for PieceProductSlot and CustomField with ModelType
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -184,4 +184,40 @@ class CustomField
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTypeComposant(): ?ModelType
|
||||
{
|
||||
return $this->typeComposant;
|
||||
}
|
||||
|
||||
public function setTypeComposant(?ModelType $typeComposant): static
|
||||
{
|
||||
$this->typeComposant = $typeComposant;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTypePiece(): ?ModelType
|
||||
{
|
||||
return $this->typePiece;
|
||||
}
|
||||
|
||||
public function setTypePiece(?ModelType $typePiece): static
|
||||
{
|
||||
$this->typePiece = $typePiece;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTypeProduct(): ?ModelType
|
||||
{
|
||||
return $this->typeProduct;
|
||||
}
|
||||
|
||||
public function setTypeProduct(?ModelType $typeProduct): static
|
||||
{
|
||||
$this->typeProduct = $typeProduct;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Entity\MachinePieceLink;
|
||||
use App\Entity\MachineProductLink;
|
||||
use App\Entity\ModelType;
|
||||
use App\Entity\Piece;
|
||||
use App\Entity\PieceProductSlot;
|
||||
use App\Entity\Product;
|
||||
use App\Entity\Profile;
|
||||
use App\Entity\Site;
|
||||
@@ -236,13 +237,27 @@ abstract class AbstractApiTestCase extends ApiTestCase
|
||||
string $name = 'Custom Field',
|
||||
string $type = 'text',
|
||||
?Machine $machine = null,
|
||||
?ModelType $typeComposant = null,
|
||||
?ModelType $typePiece = null,
|
||||
?ModelType $typeProduct = null,
|
||||
int $orderIndex = 0,
|
||||
): CustomField {
|
||||
$cf = new CustomField();
|
||||
$cf->setName($name);
|
||||
$cf->setType($type);
|
||||
$cf->setOrderIndex($orderIndex);
|
||||
if (null !== $machine) {
|
||||
$cf->setMachine($machine);
|
||||
}
|
||||
if (null !== $typeComposant) {
|
||||
$cf->setTypeComposant($typeComposant);
|
||||
}
|
||||
if (null !== $typePiece) {
|
||||
$cf->setTypePiece($typePiece);
|
||||
}
|
||||
if (null !== $typeProduct) {
|
||||
$cf->setTypeProduct($typeProduct);
|
||||
}
|
||||
|
||||
$em = $this->getEntityManager();
|
||||
$em->persist($cf);
|
||||
@@ -394,6 +409,31 @@ abstract class AbstractApiTestCase extends ApiTestCase
|
||||
return $slot;
|
||||
}
|
||||
|
||||
protected function createPieceProductSlot(
|
||||
Piece $piece,
|
||||
?ModelType $typeProduct = null,
|
||||
?Product $selectedProduct = null,
|
||||
?string $familyCode = null,
|
||||
int $position = 0,
|
||||
): PieceProductSlot {
|
||||
$slot = new PieceProductSlot();
|
||||
$slot->setPiece($piece);
|
||||
$slot->setFamilyCode($familyCode);
|
||||
$slot->setPosition($position);
|
||||
if (null !== $typeProduct) {
|
||||
$slot->setTypeProduct($typeProduct);
|
||||
}
|
||||
if (null !== $selectedProduct) {
|
||||
$slot->setSelectedProduct($selectedProduct);
|
||||
}
|
||||
|
||||
$em = $this->getEntityManager();
|
||||
$em->persist($slot);
|
||||
$em->flush();
|
||||
|
||||
return $slot;
|
||||
}
|
||||
|
||||
// ── Assertion helpers ───────────────────────────────────────────
|
||||
|
||||
protected function assertJsonContainsHydraCollection(): void
|
||||
|
||||
Reference in New Issue
Block a user