Files
crm_ecosplay/tests/Entity/AdvertLineTest.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

144 lines
4.2 KiB
PHP

<?php
namespace App\Tests\Entity;
use App\Entity\Advert;
use App\Entity\AdvertLine;
use App\Entity\OrderNumber;
use PHPUnit\Framework\TestCase;
class AdvertLineTest extends TestCase
{
private Advert $advert;
protected function setUp(): void
{
$orderNumber = new OrderNumber('04/2026-00001');
$this->advert = $this->createStub(Advert::class);
}
public function testConstructorDefaults(): void
{
$line = new AdvertLine($this->advert, 'Service Web');
$this->assertSame($this->advert, $line->getAdvert());
$this->assertSame('Service 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());
$this->assertNull($line->getId());
}
public function testConstructorWithAllParams(): void
{
$line = new AdvertLine($this->advert, 'Hébergement', '120.00', 3);
$this->assertSame('Hébergement', $line->getTitle());
$this->assertSame('120.00', $line->getPriceHt());
$this->assertSame(3, $line->getPos());
}
public function testSetPos(): void
{
$line = new AdvertLine($this->advert, 'Test');
$result = $line->setPos(5);
$this->assertSame(5, $line->getPos());
$this->assertSame($line, $result); // fluent interface
}
public function testSetTitle(): void
{
$line = new AdvertLine($this->advert, 'Initial');
$result = $line->setTitle('Updated Title');
$this->assertSame('Updated Title', $line->getTitle());
$this->assertSame($line, $result);
}
public function testSetDescription(): void
{
$line = new AdvertLine($this->advert, 'Test');
$result = $line->setDescription('Une description détaillée');
$this->assertSame('Une description détaillée', $line->getDescription());
$this->assertSame($line, $result);
}
public function testSetDescriptionNull(): void
{
$line = new AdvertLine($this->advert, 'Test');
$line->setDescription('some desc');
$line->setDescription(null);
$this->assertNull($line->getDescription());
}
public function testSetPriceHt(): void
{
$line = new AdvertLine($this->advert, 'Test');
$result = $line->setPriceHt('250.50');
$this->assertSame('250.50', $line->getPriceHt());
$this->assertSame($line, $result);
}
public function testSetType(): void
{
$line = new AdvertLine($this->advert, 'Test');
$result = $line->setType('hosting');
$this->assertSame('hosting', $line->getType());
$this->assertSame($line, $result);
}
public function testSetTypeNull(): void
{
$line = new AdvertLine($this->advert, 'Test');
$line->setType('domain');
$line->setType(null);
$this->assertNull($line->getType());
}
public function testSetServiceId(): void
{
$line = new AdvertLine($this->advert, 'Test');
$result = $line->setServiceId(42);
$this->assertSame(42, $line->getServiceId());
$this->assertSame($line, $result);
}
public function testSetServiceIdNull(): void
{
$line = new AdvertLine($this->advert, 'Test');
$line->setServiceId(99);
$line->setServiceId(null);
$this->assertNull($line->getServiceId());
}
public function testFluentInterfaceChainingAllSetters(): void
{
$line = new AdvertLine($this->advert, 'Chained');
$result = $line
->setPos(2)
->setTitle('New Title')
->setDescription('Desc')
->setPriceHt('99.99')
->setType('ndd')
->setServiceId(7);
$this->assertSame(2, $line->getPos());
$this->assertSame('New Title', $line->getTitle());
$this->assertSame('Desc', $line->getDescription());
$this->assertSame('99.99', $line->getPriceHt());
$this->assertSame('ndd', $line->getType());
$this->assertSame(7, $line->getServiceId());
$this->assertSame($line, $result);
}
}