97d7cacd2c
Ecriture du formulaire principal transporteur (M4, WT4) : POST/PATCH via CarrierProcessor + CarrierFieldNormalizer, contraintes conditionnelles sur l'entite Carrier. - RG-4.01 : POST qualimatCarrier -> certificationType=QUALIMAT + FK persistee ; cas LIOT (name=LIOT) -> certification non requise, liotPlates accepte. - RG-4.02 : certificationType=AUTRE sans dischargeDocument -> 422 (Assert\Callback). - RG-4.03 : isChartered=true sans indexationRate/containerType/volumeM3 -> 422. - RG-4.12 : doublon de nom (parmi actifs) -> 409 (index partiel uq_carrier_name_active). - RG-4.13 : normalisation serveur (name UPPER, liotPlates ;-split/trim/UPPER) + methodes personne/telephone/email pour les sous-ressources Contact (WT7). - RG-4.14 : PATCH isArchived exige transport.carriers.archive (Admin seul), mode strict -> 403 + 422 si autre champ ; restauration en conflit -> 409. Operations Post/Patch ajoutees a l'ApiResource (lecture posee au WT3 conservee). RG conditionnelles portees par validateMainFormConsistency (Assert\Callback + ->atPath()) pour un propertyPath mappable inline (useFormErrors, ERP-101). certificationType / containerType whitelistes dans EXCLUDED_LENGTH_MIRROR (Choice borne deja les valeurs, miroir SupplierAddress::addressType). Tests : CarrierWriteApiTest (RG-4.01->4.03/4.12->4.14), CarrierRBACMatrixTest (matrice bureau/compta/commerciale/usine), CarrierArchiveTest (409 restauration), CarrierFieldNormalizerTest (RG-4.13). make test vert (750).
70 lines
2.5 KiB
PHP
70 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Module\Transport\Application;
|
|
|
|
use App\Module\Transport\Application\Service\CarrierFieldNormalizer;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Normalisation serveur des champs texte du repertoire transporteurs (RG-4.13 +
|
|
* cas LIOT RG-4.01). Jumeau de SupplierFieldNormalizerTest (M2), enrichi de
|
|
* normalizeLiotPlates.
|
|
*
|
|
* @internal
|
|
*/
|
|
final class CarrierFieldNormalizerTest extends TestCase
|
|
{
|
|
private CarrierFieldNormalizer $normalizer;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->normalizer = new CarrierFieldNormalizer();
|
|
}
|
|
|
|
public function testNameIsUpperCasedAndTrimmed(): void
|
|
{
|
|
self::assertSame('TRANSPORTS X', $this->normalizer->normalizeName(' transports x '));
|
|
self::assertNull($this->normalizer->normalizeName(null));
|
|
}
|
|
|
|
public function testPersonNameIsTitleCased(): void
|
|
{
|
|
self::assertSame('Jean Dupont', $this->normalizer->normalizePersonName('JEAN dupont'));
|
|
self::assertNull($this->normalizer->normalizePersonName(' '));
|
|
self::assertNull($this->normalizer->normalizePersonName(null));
|
|
}
|
|
|
|
public function testEmailIsLowerCased(): void
|
|
{
|
|
self::assertSame('marie.martin@seed.test', $this->normalizer->normalizeEmail(' Marie.MARTIN@Seed.Test '));
|
|
self::assertNull($this->normalizer->normalizeEmail(' '));
|
|
self::assertNull($this->normalizer->normalizeEmail(null));
|
|
}
|
|
|
|
public function testPhoneKeepsDigitsOnly(): void
|
|
{
|
|
self::assertSame('0612345678', $this->normalizer->normalizePhone('06.12.34.56.78'));
|
|
self::assertSame('33612345678', $this->normalizer->normalizePhone('+33 6 12 34 56 78'));
|
|
self::assertNull($this->normalizer->normalizePhone('sans chiffre'));
|
|
self::assertNull($this->normalizer->normalizePhone(null));
|
|
}
|
|
|
|
/**
|
|
* RG-4.01 / RG-4.13 : la saisie « ; »-separee est decoupee, chaque plaque trim
|
|
* + UPPER, segments vides ecartes, recomposee avec "; ".
|
|
*/
|
|
public function testLiotPlatesAreSplitTrimmedUpperedAndRejoined(): void
|
|
{
|
|
self::assertSame(
|
|
'AB-123-CD; EF-456-GH',
|
|
$this->normalizer->normalizeLiotPlates('ab-123-cd ; ef-456-gh'),
|
|
);
|
|
// Segments vides (« ;; » / fin de chaine) ecartes.
|
|
self::assertSame('AB-123-CD', $this->normalizer->normalizeLiotPlates(' ab-123-cd ; ; '));
|
|
self::assertNull($this->normalizer->normalizeLiotPlates(' ; ; '));
|
|
self::assertNull($this->normalizer->normalizeLiotPlates(null));
|
|
}
|
|
}
|