test(normalization) : add tests for skeleton requirements, composant slots, piece-product relation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,9 @@ namespace App\Tests;
|
||||
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
||||
use ApiPlatform\Symfony\Bundle\Test\Client;
|
||||
use App\Entity\Composant;
|
||||
use App\Entity\ComposantPieceSlot;
|
||||
use App\Entity\ComposantProductSlot;
|
||||
use App\Entity\ComposantSubcomponentSlot;
|
||||
use App\Entity\Constructeur;
|
||||
use App\Entity\CustomField;
|
||||
use App\Entity\CustomFieldValue;
|
||||
@@ -314,6 +317,83 @@ abstract class AbstractApiTestCase extends ApiTestCase
|
||||
return $link;
|
||||
}
|
||||
|
||||
protected function createComposantPieceSlot(
|
||||
Composant $composant,
|
||||
?ModelType $typePiece = null,
|
||||
?Piece $selectedPiece = null,
|
||||
int $quantity = 1,
|
||||
int $position = 0,
|
||||
): ComposantPieceSlot {
|
||||
$slot = new ComposantPieceSlot();
|
||||
$slot->setComposant($composant);
|
||||
$slot->setQuantity($quantity);
|
||||
$slot->setPosition($position);
|
||||
if (null !== $typePiece) {
|
||||
$slot->setTypePiece($typePiece);
|
||||
}
|
||||
if (null !== $selectedPiece) {
|
||||
$slot->setSelectedPiece($selectedPiece);
|
||||
}
|
||||
|
||||
$em = $this->getEntityManager();
|
||||
$em->persist($slot);
|
||||
$em->flush();
|
||||
|
||||
return $slot;
|
||||
}
|
||||
|
||||
protected function createComposantSubcomponentSlot(
|
||||
Composant $composant,
|
||||
?string $alias = null,
|
||||
?string $familyCode = null,
|
||||
?ModelType $typeComposant = null,
|
||||
?Composant $selectedComposant = null,
|
||||
int $position = 0,
|
||||
): ComposantSubcomponentSlot {
|
||||
$slot = new ComposantSubcomponentSlot();
|
||||
$slot->setComposant($composant);
|
||||
$slot->setAlias($alias);
|
||||
$slot->setFamilyCode($familyCode);
|
||||
$slot->setPosition($position);
|
||||
if (null !== $typeComposant) {
|
||||
$slot->setTypeComposant($typeComposant);
|
||||
}
|
||||
if (null !== $selectedComposant) {
|
||||
$slot->setSelectedComposant($selectedComposant);
|
||||
}
|
||||
|
||||
$em = $this->getEntityManager();
|
||||
$em->persist($slot);
|
||||
$em->flush();
|
||||
|
||||
return $slot;
|
||||
}
|
||||
|
||||
protected function createComposantProductSlot(
|
||||
Composant $composant,
|
||||
?ModelType $typeProduct = null,
|
||||
?Product $selectedProduct = null,
|
||||
?string $familyCode = null,
|
||||
int $position = 0,
|
||||
): ComposantProductSlot {
|
||||
$slot = new ComposantProductSlot();
|
||||
$slot->setComposant($composant);
|
||||
$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