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>
80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use App\Entity\Advert;
|
|
use App\Entity\AdvertPayment;
|
|
use App\Entity\OrderNumber;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AdvertPaymentTest extends TestCase
|
|
{
|
|
private function createAdvert(): Advert
|
|
{
|
|
$order = new OrderNumber('04/2026-99001');
|
|
|
|
return new Advert($order, 'test-secret');
|
|
}
|
|
|
|
public function testConstructor(): void
|
|
{
|
|
$advert = $this->createAdvert();
|
|
$payment = new AdvertPayment($advert, AdvertPayment::TYPE_SUCCESS, '199.00');
|
|
|
|
$this->assertNull($payment->getId());
|
|
$this->assertSame($advert, $payment->getAdvert());
|
|
$this->assertSame(AdvertPayment::TYPE_SUCCESS, $payment->getType());
|
|
$this->assertSame('199.00', $payment->getAmount());
|
|
$this->assertNull($payment->getMethod());
|
|
$this->assertInstanceOf(\DateTimeImmutable::class, $payment->getCreatedAt());
|
|
}
|
|
|
|
public function testTypeRefused(): void
|
|
{
|
|
$advert = $this->createAdvert();
|
|
$payment = new AdvertPayment($advert, AdvertPayment::TYPE_REFUSED, '0.00');
|
|
|
|
$this->assertSame(AdvertPayment::TYPE_REFUSED, $payment->getType());
|
|
}
|
|
|
|
public function testMethod(): void
|
|
{
|
|
$advert = $this->createAdvert();
|
|
$payment = new AdvertPayment($advert, AdvertPayment::TYPE_SUCCESS, '50.00');
|
|
|
|
$this->assertNull($payment->getMethod());
|
|
|
|
$payment->setMethod('card');
|
|
$this->assertSame('card', $payment->getMethod());
|
|
|
|
$payment->setMethod(null);
|
|
$this->assertNull($payment->getMethod());
|
|
}
|
|
|
|
public function testMethodReturnsStatic(): void
|
|
{
|
|
$advert = $this->createAdvert();
|
|
$payment = new AdvertPayment($advert, AdvertPayment::TYPE_SUCCESS, '50.00');
|
|
|
|
$result = $payment->setMethod('sepa');
|
|
$this->assertSame($payment, $result);
|
|
}
|
|
|
|
public function testTypeConstants(): void
|
|
{
|
|
$this->assertSame('success', AdvertPayment::TYPE_SUCCESS);
|
|
$this->assertSame('refused', AdvertPayment::TYPE_REFUSED);
|
|
}
|
|
|
|
public function testCreatedAtIsImmutable(): void
|
|
{
|
|
$advert = $this->createAdvert();
|
|
$before = new \DateTimeImmutable();
|
|
$payment = new AdvertPayment($advert, AdvertPayment::TYPE_SUCCESS, '99.00');
|
|
$after = new \DateTimeImmutable();
|
|
|
|
$this->assertGreaterThanOrEqual($before, $payment->getCreatedAt());
|
|
$this->assertLessThanOrEqual($after, $payment->getCreatedAt());
|
|
}
|
|
}
|