refactor(commercial) : RG-1.03 distributor/broker by category code

ClientProcessor::hasCategoryCode (ex hasCategoryType) verifie le code de la
Category (DISTRIBUTEUR/COURTIER) et non plus le type. Filtre liste/export
renomme categoryType -> categoryCode (filtre sur category.code). Tests RG-1.03
distributor + courtier ajoutes ; factory de test adaptee au type unique CLIENT.
This commit is contained in:
Matthieu
2026-06-02 09:20:58 +02:00
parent 636f2ccb8e
commit 596f716076
8 changed files with 129 additions and 47 deletions
@@ -175,6 +175,49 @@ final class ClientApiTest extends AbstractCommercialApiTestCase
self::assertResponseStatusCodeSame(201);
}
public function testPostBrokerReferencingNonBrokerReturns422(): void
{
$client = $this->createAdminClient();
$cat = $this->createCategory('SECTEUR');
$notBroker = $this->seedClient('Pas Un Courtier', false, 'SECTEUR');
$client->request('POST', '/api/clients', [
'headers' => ['Content-Type' => self::LD],
'json' => [
'companyName' => 'Bad Broker Ref',
'firstName' => 'A',
'phonePrimary' => '0102030405',
'email' => 'badbroker@test.fr',
'categories' => ['/api/categories/'.$cat->getId()],
'broker' => '/api/clients/'.$notBroker->getId(),
],
]);
// RG-1.03 (le broker doit porter la categorie de code COURTIER)
self::assertResponseStatusCodeSame(422);
}
public function testPostValidBrokerReturns201(): void
{
$client = $this->createAdminClient();
$cat = $this->createCategory('SECTEUR');
$broker = $this->seedClient('Vrai Courtier', false, 'COURTIER');
$client->request('POST', '/api/clients', [
'headers' => ['Content-Type' => self::LD],
'json' => [
'companyName' => 'Client Avec Courtier',
'firstName' => 'A',
'phonePrimary' => '0102030405',
'email' => 'okbroker@test.fr',
'categories' => ['/api/categories/'.$cat->getId()],
'broker' => '/api/clients/'.$broker->getId(),
],
]);
self::assertResponseStatusCodeSame(201);
}
public function testListSortedByCompanyNameAscAndExcludesArchived(): void
{
$client = $this->createAdminClient();