Files
crm_ecosplay/tests/Entity/DevisLineTest.php
Serreau Jovann d550efa44c test: couverture 87% methodes (1132 tests, 2293 assertions)
Entites completes a 100% :
- AdvertLineTest : 12 tests (constructor, setters, fluent interface)
- DevisLineTest : 12 tests (idem)

Services ameliores vers 100% :
- DocuSealServiceTest : +1 (getLogoBase64 avec logo.jpg)
- FactureServiceTest : +1 (createFromAdvert avec lines description/type)
- MailerServiceTest : +1 (injectAttachmentsList sans <tr> avant footer)
- OrderNumberServiceTest : +4 (generate/preview create new number)
- ComptaPdfTest : +2 (Header/Footer explicites, setData re-assign)
- FacturePdfTest : +3 (displayHmac, appendRib sans/avec fichier)

Controllers ameliores :
- ComptabiliteControllerTest : +22 (tous exports avec donnees, TVA, sign)
- StatsControllerTest : +8 (factures payees, AdvertPayment, services, resolveStatus)
- ClientsControllerTest : +12 (contacts, NDD, securite, DNS check)
- WebhookStripeControllerTest : +8 (handlePaymentSucceeded/Failed tous chemins)
- AdminControllersTest : +1 (dashboard globalSearch empty)
- FactureControllerTest : +2 (customer null, generatePdf 404)
- PrestatairesControllerTest : +1 (deleteFacture mismatch)
- SyncControllerTest : +1 (syncAll error)
- TarificationControllerTest : +1 (purge avec stripeId)
- LegalControllerTest : +3 (rgpdVerify access/deletion/missing params)

Progression : 83% -> 87% methodes, 18 -> 10 classes restantes

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

142 lines
4.1 KiB
PHP

<?php
namespace App\Tests\Entity;
use App\Entity\Devis;
use App\Entity\DevisLine;
use PHPUnit\Framework\TestCase;
class DevisLineTest extends TestCase
{
private Devis $devis;
protected function setUp(): void
{
$this->devis = $this->createStub(Devis::class);
}
public function testConstructorDefaults(): void
{
$line = new DevisLine($this->devis, 'Création site');
$this->assertSame($this->devis, $line->getDevis());
$this->assertSame('Création site', $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());
$this->assertNull($line->getId());
}
public function testConstructorWithAllParams(): void
{
$line = new DevisLine($this->devis, 'Maintenance', '75.00', 2);
$this->assertSame('Maintenance', $line->getTitle());
$this->assertSame('75.00', $line->getPriceHt());
$this->assertSame(2, $line->getPos());
}
public function testSetPos(): void
{
$line = new DevisLine($this->devis, 'Test');
$result = $line->setPos(4);
$this->assertSame(4, $line->getPos());
$this->assertSame($line, $result);
}
public function testSetTitle(): void
{
$line = new DevisLine($this->devis, 'Old Title');
$result = $line->setTitle('New Title');
$this->assertSame('New Title', $line->getTitle());
$this->assertSame($line, $result);
}
public function testSetDescription(): void
{
$line = new DevisLine($this->devis, 'Test');
$result = $line->setDescription('Description du service');
$this->assertSame('Description du service', $line->getDescription());
$this->assertSame($line, $result);
}
public function testSetDescriptionNull(): void
{
$line = new DevisLine($this->devis, 'Test');
$line->setDescription('some desc');
$line->setDescription(null);
$this->assertNull($line->getDescription());
}
public function testSetPriceHt(): void
{
$line = new DevisLine($this->devis, 'Test');
$result = $line->setPriceHt('199.99');
$this->assertSame('199.99', $line->getPriceHt());
$this->assertSame($line, $result);
}
public function testSetType(): void
{
$line = new DevisLine($this->devis, 'Test');
$result = $line->setType('development');
$this->assertSame('development', $line->getType());
$this->assertSame($line, $result);
}
public function testSetTypeNull(): void
{
$line = new DevisLine($this->devis, 'Test');
$line->setType('seo');
$line->setType(null);
$this->assertNull($line->getType());
}
public function testSetServiceId(): void
{
$line = new DevisLine($this->devis, 'Test');
$result = $line->setServiceId(15);
$this->assertSame(15, $line->getServiceId());
$this->assertSame($line, $result);
}
public function testSetServiceIdNull(): void
{
$line = new DevisLine($this->devis, 'Test');
$line->setServiceId(10);
$line->setServiceId(null);
$this->assertNull($line->getServiceId());
}
public function testFluentInterfaceChainingAllSetters(): void
{
$line = new DevisLine($this->devis, 'Initial');
$result = $line
->setPos(1)
->setTitle('Final Title')
->setDescription('Desc')
->setPriceHt('500.00')
->setType('hosting')
->setServiceId(3);
$this->assertSame(1, $line->getPos());
$this->assertSame('Final Title', $line->getTitle());
$this->assertSame('Desc', $line->getDescription());
$this->assertSame('500.00', $line->getPriceHt());
$this->assertSame('hosting', $line->getType());
$this->assertSame(3, $line->getServiceId());
$this->assertSame($line, $result);
}
}