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>
53 lines
2.0 KiB
PHP
53 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Module\Commercial\Api;
|
|
|
|
use App\Module\Commercial\Domain\Entity\Client as ClientEntity;
|
|
|
|
/**
|
|
* Test fonctionnel du mode strict PATCH multi-groupes (RG-1.28) — ERP-60.
|
|
*
|
|
* Le cas est deja couvert en unitaire (ClientProcessorTest) ; on en ajoute la
|
|
* preuve fonctionnelle HTTP, SANS dependre d'un role metier : un utilisateur
|
|
* portant `commercial.clients.manage` mais PAS `commercial.clients.accounting.manage`
|
|
* qui envoie un PATCH melant un champ principal (companyName) et un champ
|
|
* comptable (siren) recoit un 403 sur l'ENSEMBLE du payload — aucun champ n'est
|
|
* applique (pas de filtrage silencieux).
|
|
*
|
|
* ⚠ La matrice differenciee par role metier (Bureau / Compta / Commerciale) est
|
|
* DELEGUEE a ERP-74 (#493). Ici on n'utilise qu'un user mono-permission.
|
|
*
|
|
* @internal
|
|
*/
|
|
final class ClientPatchStrictTest extends AbstractCommercialApiTestCase
|
|
{
|
|
private const string MERGE = 'application/merge-patch+json';
|
|
|
|
public function testMixedGroupsPatchWithoutAccountingPermissionIsForbidden(): void
|
|
{
|
|
$seed = $this->seedClient('Strict Mix');
|
|
$credentials = $this->createUserWithPermission('commercial.clients.manage');
|
|
$client = $this->authenticatedClient($credentials['username'], $credentials['password']);
|
|
|
|
$client->request('PATCH', '/api/clients/'.$seed->getId(), [
|
|
'headers' => ['Content-Type' => self::MERGE],
|
|
'json' => [
|
|
'companyName' => 'Renamed Strict',
|
|
'siren' => '123456789',
|
|
],
|
|
]);
|
|
|
|
// RG-1.28 : 403 strict (le champ comptable siren exige accounting.manage).
|
|
self::assertResponseStatusCodeSame(403);
|
|
|
|
// Aucun champ applique : le companyName d'origine est intact.
|
|
$em = $this->getEm();
|
|
$em->clear();
|
|
$reloaded = $em->getRepository(ClientEntity::class)->find($seed->getId());
|
|
self::assertNotNull($reloaded);
|
|
self::assertSame('STRICT MIX', $reloaded->getCompanyName());
|
|
}
|
|
}
|