test(commercial) : cover RG-1.01..1.29 except role-gated (M1)
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user