test(logistique) : durcissement tests M5 — embed FOURNISSEUR symetrique + propertyPath 422 (ERP-187)

- WeighingTicketSerializationContractTest : couvre la branche FOURNISSEUR (supplier embarque, client null) en plus de CLIENT (piege #1 symetrique, spec § 4.0.bis).
- AbstractWeighingTicketApiTestCase : helpers seedTestSupplier + payload FOURNISSEUR + purge supplier au tearDown.
- WeighbridgeReadingApiTest : les 422 (mode invalide / poids manquant) verifient desormais le propertyPath (garde-fou ERP-101), pas seulement le code HTTP.
- NetWeightTest : docbloc isNew/contains() clarifie.
This commit is contained in:
Matthieu
2026-06-18 14:26:33 +02:00
parent ab15452459
commit 1bb6334baa
4 changed files with 138 additions and 16 deletions
@@ -31,7 +31,7 @@ final class NetWeightTest extends TestCase
{
public function testNetIsFullMinusEmptyWhenBothPresent(): void
{
$ticket = (new WeighingTicket())
$ticket = new WeighingTicket()
->setEmptyWeight(7150)
->setFullWeight(14300)
;
@@ -44,7 +44,7 @@ final class NetWeightTest extends TestCase
public function testNetIsNullWhenFullWeightMissing(): void
{
$ticket = (new WeighingTicket())->setEmptyWeight(7150);
$ticket = new WeighingTicket()->setEmptyWeight(7150);
$this->makeProcessor(isNew: true)->process($ticket, new Post());
@@ -53,7 +53,7 @@ final class NetWeightTest extends TestCase
public function testNetIsNullWhenEmptyWeightMissing(): void
{
$ticket = (new WeighingTicket())->setFullWeight(14300);
$ticket = new WeighingTicket()->setFullWeight(14300);
$this->makeProcessor(isNew: true)->process($ticket, new Post());
@@ -76,7 +76,7 @@ final class NetWeightTest extends TestCase
*/
public function testNetIsRecomputedOnPatch(): void
{
$ticket = (new WeighingTicket())
$ticket = new WeighingTicket()
->setSite($this->site())
->setEmptyWeight(7150)
->setFullWeight(20000)
@@ -88,9 +88,11 @@ final class NetWeightTest extends TestCase
}
/**
* Construit le Processor avec des dependances stubbees. `isNew` pilote
* EntityManager::contains() : false => creation (POST, attribution site/numero),
* true => entite geree (PATCH, ni site ni numero retouches).
* Construit le Processor avec des dependances stubbees. `isNew` porte le sens
* metier : true => creation (POST, attribution site/numero), false => entite
* geree (PATCH, ni site ni numero retouches). Il est INVERSE pour stubber
* EntityManager::contains() (qui renvoie true pour une entite deja persistee),
* d'ou `willReturn(!$isNew)` plus bas.
*/
private function makeProcessor(bool $isNew): WeighingTicketProcessor
{
@@ -123,7 +125,7 @@ final class NetWeightTest extends TestCase
{
// getId() reste null : numberAllocator et dsdAllocator sont stubbes, donc
// aucune requete reelle ne depend de l'id du site.
return (new Site('Châtellerault', 'Rue du Pont', null, '86000', 'Châtellerault', '#112233'))
return new Site('Châtellerault', 'Rue du Pont', null, '86000', 'Châtellerault', '#112233')
->setCode('86')
;
}