Files
crm_ecosplay/tests/Entity/DocusealEventTest.php
Serreau Jovann 79c55ba0f9 test: ajout 163 tests unitaires (668->831) avec couverture 73%
Entites (76 tests) :
- PrestataireTest : constructeur, setters, getFullAddress, getTotalPaidHt
- FacturePrestataireTest : constructeur, getPeriodLabel 12 mois, Vich upload
- AdvertPaymentTest : constructeur, types constants, method
- AdvertEventTest : constructeur, getTypeLabel, 5 types + fallback
- FactureLineTest : constructeur, setters, optionnels nullable
- ActionLogTest : constructeur, 10 action constants, severity
- PaymentReminderTest : 8 steps, getStepLabel, getSeverity
- DocusealEventTest : constructeur, nullable fields

Commands (16 tests) :
- ReminderFacturesPrestataireCommandTest : 6 scenarios (aucun presta,
  tous OK, factures manquantes, SIRET vide, mois different)
- PaymentReminderCommandTest : 10 scenarios (skip recent, J+15 emails,
  suspension, termination, exception handling)

Services PDF (24 tests) :
- ComptaPdfTest : empty/FEC/multi-page, totaux Debit/Credit
- RapportFinancierPdfTest : recettes/depenses, bilan equilibre/deficit/excedent
- FacturePdfTest : lignes, TVA, customer address, paid badge, multi-page

Controllers (47 tests) :
- ComptabiliteControllerTest : 18 tests (index, 7 exports CSV, 2 JSON,
  4 PDF, 2 rapport financier)
- PrestatairesControllerTest : 19 tests (CRUD, factures, SIRET proxy)
- FactureControllerTest : 6 tests (search, send)
- FactureVerifyControllerTest : 4 tests (HMAC valid/invalid/not found)

Couverture : 51%->60% classes, 58%->73% methodes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 23:57:42 +02:00

76 lines
2.6 KiB
PHP

<?php
namespace App\Tests\Entity;
use App\Entity\DocusealEvent;
use PHPUnit\Framework\TestCase;
class DocusealEventTest extends TestCase
{
public function testConstructorMinimalArgs(): void
{
$event = new DocusealEvent('submission', 'completed');
$this->assertNull($event->getId());
$this->assertSame('submission', $event->getType());
$this->assertSame('completed', $event->getEventType());
$this->assertNull($event->getSubmissionId());
$this->assertNull($event->getSubmitterId());
$this->assertNull($event->getPayload());
$this->assertInstanceOf(\DateTimeImmutable::class, $event->getCreatedAt());
}
public function testConstructorWithAllArgs(): void
{
$payload = '{"submission_id":42,"submitter_id":7,"status":"completed"}';
$event = new DocusealEvent('submitter', 'opened', 42, 7, $payload);
$this->assertSame('submitter', $event->getType());
$this->assertSame('opened', $event->getEventType());
$this->assertSame(42, $event->getSubmissionId());
$this->assertSame(7, $event->getSubmitterId());
$this->assertSame($payload, $event->getPayload());
}
public function testSubmissionIdNullable(): void
{
$event = new DocusealEvent('submission', 'completed', null, null);
$this->assertNull($event->getSubmissionId());
}
public function testSubmitterIdNullable(): void
{
$event = new DocusealEvent('submission', 'completed', 10, null);
$this->assertSame(10, $event->getSubmissionId());
$this->assertNull($event->getSubmitterId());
}
public function testPayloadNullable(): void
{
$event = new DocusealEvent('submission', 'completed', 1, 2, null);
$this->assertNull($event->getPayload());
}
public function testCreatedAtTimestamp(): void
{
$before = new \DateTimeImmutable();
$event = new DocusealEvent('submission', 'completed');
$after = new \DateTimeImmutable();
$this->assertGreaterThanOrEqual($before, $event->getCreatedAt());
$this->assertLessThanOrEqual($after, $event->getCreatedAt());
}
public function testTypesAreImmutableAfterConstruction(): void
{
$event = new DocusealEvent('form', 'signed', 100, 200, '{}');
// Getters must return exactly what was passed in
$this->assertSame('form', $event->getType());
$this->assertSame('signed', $event->getEventType());
$this->assertSame(100, $event->getSubmissionId());
$this->assertSame(200, $event->getSubmitterId());
$this->assertSame('{}', $event->getPayload());
}
}