120058049c
Auto Tag Develop / tag (push) Successful in 7s
Dernier wagon de la stack back M1. ERP-60 = polish stack + couverture de tests PHPUnit NON dépendante des rôles métier (cf. spec § 7 / § 8.1). ## Phase 0 — polish stack (déjà mergé dans les branches basses via rebase) - ERP-59 : route sidebar `/clients` (au lieu de `/commercial/clients`), cohérente avec `/suppliers`. - One-liner pagination Client abandonné : `pagination_client_enabled: true` est déjà le défaut global → `?pagination=false` marche déjà sur `/api/clients` (décision P7). ## Phase 1 — tests (combler les trous, zéro duplication) 8 nouvelles suites couvrant les RG non encore testées par ERP-55/56/57/58 : - `ClientFormulaireMainTest` — RG-1.02 (téléphone secondaire, max 2). - `ClientAddressTest` — RG-1.06/07/08 + RG-1.11 (CHECK BDD prospect/billing). - `ClientUniquenessTest` — RG-1.15/1.17 (Q4 : SIREN/email NON uniques). - `ClientArchiveTest` — **RG-1.23 : 409 restauration en conflit (gap P1)**. - `ClientAuditTest` — RG-1.27 (created* figés / updatedBy modificateur) + iban/bic présents dans le diff audité. - `ClientMigrationTest` — index partiel unique `uq_client_company_name_active` (1 seul) ; pas d'index siren/email. - `ClientSecurityTest` — 401 anonyme + 403 sans `commercial.clients.view`. - `ClientPatchStrictTest` — RG-1.28 (403 strict mix de groupes, fonctionnel). Cahier de test complet (mapping de TOUTES les RG → test) : `docs/specs/M1-clients/cahier-test-back-M1.md`. ## Délégué à ERP-74 (#493) Matrice RBAC différenciée (bureau/compta/commerciale/usine) + RG-1.04 fonctionnel — exigent les rôles métier seedés après le merge de la stack. ## Gaps documentés (cahier) - RG-1.29 validation écriture (catégorie type sur adresse → 422) non implémentée back (hors § 8.1, ticket test-only). - Violations CHECK adresse → rejet (≥400) sans mapping fin 422 (amélioration possible). ## Vérifs `make db-reset && make php-cs-fixer-allow-risky && make test` → **421 tests OK, 1386 assertions, 0 risky**. Nouveaux tests : 17, 71 assertions. --------- Co-authored-by: Matthieu <contact@malio.fr> Reviewed-on: #38 Co-authored-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr> Co-committed-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr>
85 lines
3.2 KiB
PHP
85 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Module\Commercial\Api;
|
|
|
|
use App\Module\Commercial\Domain\Entity\Client as ClientEntity;
|
|
|
|
/**
|
|
* Tests fonctionnels du formulaire principal — combler les trous (ERP-60).
|
|
*
|
|
* RG-1.01 (prenom OU nom obligatoire) et RG-1.03 (distributor/broker exclusifs
|
|
* + type de categorie) sont DEJA couverts par ClientApiTest (ERP-55) : on ne les
|
|
* reduplique pas ici. Ce fichier ne couvre que RG-1.02 (telephone secondaire),
|
|
* non encore testee.
|
|
*
|
|
* @internal
|
|
*/
|
|
final class ClientFormulaireMainTest extends AbstractCommercialApiTestCase
|
|
{
|
|
private const string LD = 'application/ld+json';
|
|
|
|
/**
|
|
* RG-1.02 : le telephone secondaire est optionnel mais persiste (2 colonnes
|
|
* distinctes). Verifie aussi la normalisation chiffres-seuls (RG-1.20) sur
|
|
* la colonne secondaire.
|
|
*/
|
|
public function testPostPersistsSecondaryPhoneNormalized(): void
|
|
{
|
|
$client = $this->createAdminClient();
|
|
$cat = $this->createCategory('SECTEUR');
|
|
|
|
$data = $client->request('POST', '/api/clients', [
|
|
'headers' => ['Content-Type' => self::LD],
|
|
'json' => [
|
|
'companyName' => 'Two Phones SARL',
|
|
'firstName' => 'A',
|
|
'phonePrimary' => '06.12.34.56.78',
|
|
'phoneSecondary' => '05 49 00 11 22',
|
|
'email' => 'twophones@test.fr',
|
|
'categories' => ['/api/categories/'.$cat->getId()],
|
|
],
|
|
])->toArray();
|
|
|
|
self::assertResponseStatusCodeSame(201);
|
|
self::assertSame('0612345678', $data['phonePrimary']);
|
|
self::assertSame('0549001122', $data['phoneSecondary']);
|
|
}
|
|
|
|
/**
|
|
* RG-1.02 : maximum 2 telephones — le modele n'expose que phonePrimary et
|
|
* phoneSecondary. Un eventuel 3e champ envoye par un appel API direct est
|
|
* ignore (aucune 3e colonne), il ne peut donc pas creer un troisieme numero.
|
|
*/
|
|
public function testThirdPhoneFieldIsIgnored(): void
|
|
{
|
|
$client = $this->createAdminClient();
|
|
$cat = $this->createCategory('SECTEUR');
|
|
|
|
$data = $client->request('POST', '/api/clients', [
|
|
'headers' => ['Content-Type' => self::LD],
|
|
'json' => [
|
|
'companyName' => 'Third Phone SARL',
|
|
'firstName' => 'A',
|
|
'phonePrimary' => '0612345678',
|
|
'phoneSecondary' => '0549001122',
|
|
'phoneTertiary' => '0700000000',
|
|
'email' => 'thirdphone@test.fr',
|
|
'categories' => ['/api/categories/'.$cat->getId()],
|
|
],
|
|
])->toArray();
|
|
|
|
self::assertResponseStatusCodeSame(201);
|
|
// Le champ inconnu est ignore par le denormaliseur : il n'apparait pas
|
|
// dans la representation et n'a pas ete persiste.
|
|
self::assertArrayNotHasKey('phoneTertiary', $data);
|
|
|
|
// Confirmation cote base : seules les 2 colonnes telephone existent.
|
|
$persisted = $this->getEm()->getRepository(ClientEntity::class)->find($data['id']);
|
|
self::assertNotNull($persisted);
|
|
self::assertSame('0612345678', $persisted->getPhonePrimary());
|
|
self::assertSame('0549001122', $persisted->getPhoneSecondary());
|
|
}
|
|
}
|