3fe0f676f6
Auto Tag Develop / tag (push) Successful in 11s
Ticket Lesstime #139 (M3 — Répertoire prestataires, position 1.9). DoD back avant le front : suite PHPUnit consolidée sur la matrice § 8.1 + captures JSON réelles dans la spec § 4.0.bis. ## Contenu - **Fix réfs comptables** : `provider:read:accounting` ajouté sur `TvaMode`/`PaymentDelay`/`PaymentType`/`Bank` — sans ça elles sortaient en IRI nu dans le détail prestataire (réplique du fix ERP-92 du M2, piège #1 § 4.0.bis). - **`ProviderSerializationContractTest`** (13 tests) : gating RIB/scalaires par omission, réfs compta en objet `{id,code,label}`, `isArchived`, embed categories/sites liste+détail, sous-collections, enveloppe AP4 ; `testDodReferenceJsonShape` dumpe le JSON réel (`PROVIDER_DOD_DUMP=1`). - **`ProviderAuditTest`** (5 tests) : create/update/archive (`technique.Provider`), iban/bic dans le diff (`technique.ProviderRib`, pas dAuditIgnore), trace M2M `sites`. - **`ProviderListTest`** étendu : `?pagination=false`, anti-N+1, filtre `?typeCode=PRESTATAIRE`. - **`ProviderRbacGatingTest`** étendu : restauration en conflit de nom → 409 (RG-3.14). - **`ProviderFixtures`** (§ 8.4) : démo idempotente (complet VIREMENT+banque+RIB, LCR+RIB, CHEQUE multi-cat, minimal, archivé) répartie sur sites 86/17/82 ; skip en env `test`. - Helper `seedCompleteProvider` ; spec § 4.0.bis : gabarits remplacés par les captures réelles (liste + détail avec/sans accounting.view). ## Vérifications - `make php-cs-fixer-allow-risky` → 0 fichier - `make test` → OK, 677 tests, 3328 assertions (garde-fous globaux verts) ## Notes - MR stackée sur ERP-138 (base = sa branche). - Fixtures démo exercées en dev via `make fixtures` (autowiring vérifié). --------- Co-authored-by: Matthieu <contact@malio.fr> Reviewed-on: #100
86 lines
3.3 KiB
PHP
86 lines
3.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Module\Technique\Api;
|
|
|
|
/**
|
|
* Tests fonctionnels des RG comptables inter-champs portees par les Assert\Callback
|
|
* de l'entite Provider (M3, RG-3.07 / RG-3.08), via le PATCH de l'onglet
|
|
* Comptabilite (groupe provider:write:accounting). On asserte le code HTTP et le
|
|
* propertyPath de la violation (consommable par extractApiViolations cote front,
|
|
* ERP-101). Jumeau de SupplierAccountingApiTest (M2), sans le bloc « completude de
|
|
* l'onglet » : le prestataire est minimal et n'impose pas les six scalaires
|
|
* comptables (spec M3 § 3.1).
|
|
*
|
|
* @internal
|
|
*/
|
|
final class ProviderAccountingValidationTest extends AbstractProviderApiTestCase
|
|
{
|
|
// === RG-3.07 : Virement impose une banque ===
|
|
|
|
public function testVirementWithoutBankReturns422OnBankPath(): void
|
|
{
|
|
$client = $this->createAdminClient();
|
|
$seed = $this->seedProvider('Virement No Bank');
|
|
|
|
$response = $client->request('PATCH', '/api/providers/'.$seed->getId(), [
|
|
'headers' => ['Content-Type' => self::MERGE, 'Accept' => self::LD],
|
|
'json' => ['paymentType' => '/api/payment_types/'.$this->paymentType('VIREMENT')->getId()],
|
|
]);
|
|
|
|
self::assertResponseStatusCodeSame(422);
|
|
self::assertArrayHasKey('bank', $this->violationsByPath($response->toArray(false)));
|
|
}
|
|
|
|
public function testVirementWithBankReturns200(): void
|
|
{
|
|
$client = $this->createAdminClient();
|
|
$seed = $this->seedProvider('Virement With Bank');
|
|
|
|
$client->request('PATCH', '/api/providers/'.$seed->getId(), [
|
|
'headers' => ['Content-Type' => self::MERGE],
|
|
'json' => [
|
|
'paymentType' => '/api/payment_types/'.$this->paymentType('VIREMENT')->getId(),
|
|
'bank' => '/api/banks/'.$this->bank('SG')->getId(),
|
|
],
|
|
]);
|
|
|
|
self::assertResponseStatusCodeSame(200);
|
|
}
|
|
|
|
// === RG-3.08 : LCR impose au moins un RIB (volet ecriture du formulaire) ===
|
|
|
|
public function testLcrWithoutRibReturns422OnPaymentTypePath(): void
|
|
{
|
|
$client = $this->createAdminClient();
|
|
$seed = $this->seedProvider('Lcr No Rib');
|
|
|
|
$response = $client->request('PATCH', '/api/providers/'.$seed->getId(), [
|
|
'headers' => ['Content-Type' => self::MERGE, 'Accept' => self::LD],
|
|
'json' => ['paymentType' => '/api/payment_types/'.$this->paymentType('LCR')->getId()],
|
|
]);
|
|
|
|
self::assertResponseStatusCodeSame(422);
|
|
// Miroir client : violation portee sur `paymentType` (select « Type de
|
|
// règlement »), les RIB n'ayant pas de champ de formulaire pour l'ancrer.
|
|
self::assertArrayHasKey('paymentType', $this->violationsByPath($response->toArray(false)));
|
|
}
|
|
|
|
public function testLcrWithRibReturns200(): void
|
|
{
|
|
$client = $this->createAdminClient();
|
|
$seed = $this->seedProvider('Lcr With Rib');
|
|
$this->addRib($seed);
|
|
|
|
$client->request('PATCH', '/api/providers/'.$seed->getId(), [
|
|
'headers' => ['Content-Type' => self::MERGE],
|
|
'json' => ['paymentType' => '/api/payment_types/'.$this->paymentType('LCR')->getId()],
|
|
]);
|
|
|
|
self::assertResponseStatusCodeSame(200);
|
|
}
|
|
|
|
// violationsByPath() : helper mutualise dans AbstractProviderApiTestCase.
|
|
}
|