merge: integrate origin/develop into ERP-107
Pull Request — Quality gate / Backend (PHP CS + PHPUnit) (pull_request) Successful in 1m48s
Pull Request — Quality gate / Frontend (lint + Vitest + build) (pull_request) Successful in 1m17s

Resout les conflits avec la suppression du contact inline du Client (#57,
ERP-104) : les champs firstName/lastName/phones/email ne sont plus portes par
Client. Les messages de validation FR correspondants vivent desormais sur
ClientContact. Le test fonctionnel du message email FR est recible sur la
sous-ressource POST /clients/{id}/contacts.
This commit is contained in:
Matthieu
2026-06-04 10:15:04 +02:00
65 changed files with 6050 additions and 797 deletions
@@ -66,6 +66,34 @@ final class ClientSubResourceApiTest extends AbstractCommercialApiTestCase
self::assertResponseStatusCodeSame(422);
}
/**
* ERP-107 : une violation de contrainte sort avec un message FR explicite ET
* un `propertyPath` rattache au champ (consommable par useFormErrors /
* mapViolationsToRecord cote front, ERP-101). On verifie le JSON 422 reel.
*/
public function testPostContactInvalidEmailReturns422WithFrenchMessageOnField(): void
{
$client = $this->createAdminClient();
$seed = $this->seedClient('Contact Bad Email');
$response = $client->request('POST', '/api/clients/'.$seed->getId().'/contacts', [
'headers' => ['Content-Type' => self::LD, 'Accept' => self::LD],
'json' => [
'firstName' => 'Jean',
'email' => 'pas-un-email',
],
]);
self::assertResponseStatusCodeSame(422);
$byPath = [];
foreach ($response->toArray(false)['violations'] ?? [] as $v) {
$byPath[$v['propertyPath']] = $v['message'];
}
self::assertArrayHasKey('email', $byPath, 'La violation email doit porter propertyPath=email (mapping front).');
self::assertSame('L\'adresse email n\'est pas valide.', $byPath['email']);
}
public function testPatchContactNormalizes(): void
{
$client = $this->createAdminClient();
@@ -110,9 +138,10 @@ final class ClientSubResourceApiTest extends AbstractCommercialApiTestCase
public function testPostAddressNormalizesBillingEmail(): void
{
$this->skipIfSitesModuleDisabled();
$client = $this->createAdminClient();
$seed = $this->seedClient('Address Host');
$siteIri = $this->firstSiteIri();
$client = $this->createAdminClient();
$seed = $this->seedClient('Address Host');
$siteIri = $this->firstSiteIri();
$category = $this->createCategory('SECTEUR');
$data = $client->request('POST', '/api/clients/'.$seed->getId().'/addresses', [
'headers' => ['Content-Type' => self::LD],
@@ -123,6 +152,7 @@ final class ClientSubResourceApiTest extends AbstractCommercialApiTestCase
'city' => 'Châtellerault',
'street' => '1 rue du Test',
'sites' => [$siteIri],
'categories' => ['/api/categories/'.$category->getId()],
],
])->toArray();