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:
Matthieu
2026-03-13 13:44:52 +01:00
parent 0864af1439
commit f66db3f2f0
2 changed files with 76 additions and 0 deletions

View File

@@ -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