d3d00425f7
Branche l'API REST du repertoire clients (M1) sur l'entite Client preparee en ERP-54. Operations GetCollection / Get / Post / Patch (pas de Delete au M1 : l'archivage passe par PATCH isArchived). ClientProvider : - liste paginee (Paginator ORM, aligne sur la convention ERP-72) + echappatoire ?pagination=false - exclut archives + soft-deletes par defaut (RG-1.24), ?includeArchived=true reintegre les archives (RG-1.25) - tri companyName ASC (RG-1.26), filtres ?search (fuzzy companyName/lastName/ email) et ?categoryType=<code> - detail : 404 sur soft-delete, embarque contacts/adresses/ribs ClientProcessor : - normalisation serveur via ClientFieldNormalizer (RG-1.18 a 1.21) - 409 sur doublon de nom de societe (RG-1.16) ; 409 dedie sur conflit de restauration (RG-1.23) - gating par onglet : champ comptable -> accounting.manage, isArchived -> archive, mode strict 403 sur tout le payload (RG-1.28) ; archivage exclusif (RG-1.22) + pose/retrait archivedAt - regles metier RG-1.01 (prenom/nom), RG-1.03 (distributor/broker exclusifs + controle du type de categorie), RG-1.12 (Virement -> banque), RG-1.13 (LCR -> >= 1 RIB), RG-1.04 (completude Information pour le role Commerciale) Lecture comptable conditionnelle : ClientReadGroupContextBuilder ajoute le groupe client:read:accounting selon commercial.clients.accounting.view. Resolution des references categorie : CategoryReferenceDenormalizer resout les IRI vers Category quand la propriete est type-hintee par le contrat CategoryInterface (denormalisation impossible sur une interface sinon). Contrats Shared : - CategoryInterface::getCategoryTypeCode() (implemente par Category) pour la verification de type sans import inter-modules - BusinessRoleAwareInterface (implemente par User) + BusinessRoles::COMMERCIALE pour detecter le role metier ; le code de role sera seede par ERP-74 et reutilise par ERP-59/60. RG-1.04 reste dormante tant qu'aucun user ne porte ce role. Coordination stack : - chaines de permission commercial.clients.* referencees ici, declarees en ERP-59 (tests RBAC complets en ERP-60) - config globale de pagination (itemsPerPage client, max 50) portee par ERP-72 - referentiels comptables (PaymentType/Bank/...) exposes en ERP-56 Tests : 31 tests Commercial (integration admin sur les regles metier + unitaires sur le gating, RG-1.04/1.12/1.13 et le context builder). Suite complete verte (339 tests).
57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Module\Commercial\Unit;
|
|
|
|
use App\Module\Commercial\Application\Service\ClientFieldNormalizer;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Tests unitaires de la normalisation serveur (RG-1.18 a RG-1.21).
|
|
*
|
|
* @internal
|
|
*/
|
|
final class ClientFieldNormalizerTest extends TestCase
|
|
{
|
|
private ClientFieldNormalizer $normalizer;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->normalizer = new ClientFieldNormalizer();
|
|
}
|
|
|
|
public function testCompanyNameIsUppercased(): void
|
|
{
|
|
// RG-1.18
|
|
self::assertSame('ACME SAS', $this->normalizer->normalizeCompanyName(' acme sas '));
|
|
self::assertNull($this->normalizer->normalizeCompanyName(null));
|
|
}
|
|
|
|
public function testPersonNameIsTitleCased(): void
|
|
{
|
|
// RG-1.19
|
|
self::assertSame('Jean', $this->normalizer->normalizePersonName('JEAN'));
|
|
self::assertSame('Dupont', $this->normalizer->normalizePersonName('dupont'));
|
|
self::assertNull($this->normalizer->normalizePersonName(' '));
|
|
self::assertNull($this->normalizer->normalizePersonName(null));
|
|
}
|
|
|
|
public function testEmailIsLowercased(): void
|
|
{
|
|
// RG-1.21
|
|
self::assertSame('jean.dupont@acme.fr', $this->normalizer->normalizeEmail(' Jean.DUPONT@ACME.FR '));
|
|
self::assertNull($this->normalizer->normalizeEmail(null));
|
|
self::assertNull($this->normalizer->normalizeEmail(' '));
|
|
}
|
|
|
|
public function testPhoneKeepsOnlyDigits(): void
|
|
{
|
|
// RG-1.20
|
|
self::assertSame('0612345678', $this->normalizer->normalizePhone('06.12.34.56.78'));
|
|
self::assertSame('0612345678', $this->normalizer->normalizePhone('06 12 34 56 78'));
|
|
self::assertNull($this->normalizer->normalizePhone('----'));
|
|
self::assertNull($this->normalizer->normalizePhone(null));
|
|
}
|
|
}
|