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>
121 lines
3.7 KiB
PHP
121 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use App\Entity\Facture;
|
|
use App\Entity\FactureLine;
|
|
use App\Entity\OrderNumber;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class FactureLineTest extends TestCase
|
|
{
|
|
private function createFacture(): Facture
|
|
{
|
|
$order = new OrderNumber('04/2026-88001');
|
|
|
|
return new Facture($order, 'test-secret');
|
|
}
|
|
|
|
public function testConstructorMinimalArgs(): void
|
|
{
|
|
$facture = $this->createFacture();
|
|
$line = new FactureLine($facture, 'Hébergement web');
|
|
|
|
$this->assertNull($line->getId());
|
|
$this->assertSame($facture, $line->getFacture());
|
|
$this->assertSame('Hébergement web', $line->getTitle());
|
|
$this->assertSame('0.00', $line->getPriceHt());
|
|
$this->assertSame(0, $line->getPos());
|
|
$this->assertNull($line->getDescription());
|
|
$this->assertNull($line->getType());
|
|
$this->assertNull($line->getServiceId());
|
|
}
|
|
|
|
public function testConstructorWithAllArgs(): void
|
|
{
|
|
$facture = $this->createFacture();
|
|
$line = new FactureLine($facture, 'Nom de domaine .fr', '12.00', 2);
|
|
|
|
$this->assertSame('Nom de domaine .fr', $line->getTitle());
|
|
$this->assertSame('12.00', $line->getPriceHt());
|
|
$this->assertSame(2, $line->getPos());
|
|
}
|
|
|
|
public function testTitle(): void
|
|
{
|
|
$facture = $this->createFacture();
|
|
$line = new FactureLine($facture, 'Initial');
|
|
|
|
$line->setTitle('Nouveau titre');
|
|
$this->assertSame('Nouveau titre', $line->getTitle());
|
|
}
|
|
|
|
public function testPriceHt(): void
|
|
{
|
|
$facture = $this->createFacture();
|
|
$line = new FactureLine($facture, 'Test');
|
|
|
|
$line->setPriceHt('249.99');
|
|
$this->assertSame('249.99', $line->getPriceHt());
|
|
}
|
|
|
|
public function testPos(): void
|
|
{
|
|
$facture = $this->createFacture();
|
|
$line = new FactureLine($facture, 'Test');
|
|
|
|
$this->assertSame(0, $line->getPos());
|
|
$line->setPos(5);
|
|
$this->assertSame(5, $line->getPos());
|
|
}
|
|
|
|
public function testDescription(): void
|
|
{
|
|
$facture = $this->createFacture();
|
|
$line = new FactureLine($facture, 'Test');
|
|
|
|
$this->assertNull($line->getDescription());
|
|
$line->setDescription('Description détaillée du service.');
|
|
$this->assertSame('Description détaillée du service.', $line->getDescription());
|
|
$line->setDescription(null);
|
|
$this->assertNull($line->getDescription());
|
|
}
|
|
|
|
public function testType(): void
|
|
{
|
|
$facture = $this->createFacture();
|
|
$line = new FactureLine($facture, 'Test');
|
|
|
|
$this->assertNull($line->getType());
|
|
$line->setType('hosting');
|
|
$this->assertSame('hosting', $line->getType());
|
|
$line->setType(null);
|
|
$this->assertNull($line->getType());
|
|
}
|
|
|
|
public function testServiceId(): void
|
|
{
|
|
$facture = $this->createFacture();
|
|
$line = new FactureLine($facture, 'Test');
|
|
|
|
$this->assertNull($line->getServiceId());
|
|
$line->setServiceId(42);
|
|
$this->assertSame(42, $line->getServiceId());
|
|
$line->setServiceId(null);
|
|
$this->assertNull($line->getServiceId());
|
|
}
|
|
|
|
public function testSettersReturnStatic(): void
|
|
{
|
|
$facture = $this->createFacture();
|
|
$line = new FactureLine($facture, 'Test');
|
|
|
|
$this->assertSame($line, $line->setTitle('T'));
|
|
$this->assertSame($line, $line->setPriceHt('1.00'));
|
|
$this->assertSame($line, $line->setPos(1));
|
|
$this->assertSame($line, $line->setDescription('D'));
|
|
$this->assertSame($line, $line->setType('type'));
|
|
$this->assertSame($line, $line->setServiceId(1));
|
|
}
|
|
}
|