Files
crm_ecosplay/tests/Entity/WebsiteTest.php
Serreau Jovann 8bda02888c test: couverture 83% methodes (1046 tests, 2135 assertions)
Entites completes a 100% :
- AdvertTest : 12 nouveaux (state, customer, totals, hmac, lines, payments)
- CustomerTest : 3 nouveaux (isPendingDelete, revendeurCode, updatedAt)
- DevisTest : 6 nouveaux (customer, submissionId, lines, state constants)
- FactureTest : 10 nouveaux (state, totals, isPaid, lines, hmac, splitIndex)
- OrderNumberTest : 1 nouveau (markAsUnused)
- WebsiteTest : 1 nouveau (revendeurCode)

Services completes/ameliores :
- DocuSealServiceTest : 30 nouveaux (sendDevis, resendDevis, download, compta)
- AdvertServiceTest : 6 nouveaux (isTvaEnabled, getTvaRate, computeTotals)
- DevisServiceTest : 6 nouveaux (idem)
- FactureServiceTest : 8 nouveaux (idem + createPaidFactureFromAdvert)
- MailerServiceTest : 7 nouveaux (unsubscribe headers, VCF, formatFileSize)
- MeilisearchServiceTest : 42 nouveaux (index/remove/search tous types)
- RgpdServiceTest : 6 nouveaux (sendVerificationCode, verifyCode)
- OrderNumberServiceTest : 2 nouveaux (preview/generate unused)
- TarificationServiceTest : 1 nouveau (stripe error logger)
- ComptaPdfTest : 4 nouveaux (totaux, colonnes numeriques, signature)
- FacturePdfTest : 6 nouveaux (QR code, RIB, CGV Twig, footer skip)

Controllers ameliores :
- ComptabiliteControllerTest : 13 nouveaux (JSON, PDF, sign, callback)
- StatsControllerTest : 2 nouveaux (rich data, 6-month evolution)
- SyncControllerTest : 13 nouveaux (sync 6 types + purge)
- ClientsControllerTest : 7 nouveaux (show, delete, resendWelcome)
- FactureControllerTest : 2 nouveaux (generatePdf 404, send success)
- LegalControllerTest : 6 nouveaux (rgpdVerify GET/POST)
- TarificationControllerTest : 3 nouveaux (purge paths)
- AdminControllersTest : 9 nouveaux (dashboard search, services)
- WebhookStripeControllerTest : 3 nouveaux (invalid signatures)
- KeycloakAuthenticatorTest : 4 nouveaux (groups, domain check)

Commands :
- PaymentReminderCommandTest : 1 nouveau (formalNotice step)
- TestMailCommandTest : 2 nouveaux (force-dsn success/failure)

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

102 lines
3.1 KiB
PHP

<?php
namespace App\Tests\Entity;
use App\Entity\Customer;
use App\Entity\User;
use App\Entity\Website;
use PHPUnit\Framework\TestCase;
class WebsiteTest extends TestCase
{
private function createCustomer(): Customer
{
$user = new User();
$user->setEmail('c@t.com');
$user->setFirstName('C');
$user->setLastName('T');
$user->setPassword('h');
return new Customer($user);
}
public function testConstructor(): void
{
$customer = $this->createCustomer();
$site = new Website($customer, 'Mon Site');
$this->assertNull($site->getId());
$this->assertSame($customer, $site->getCustomer());
$this->assertSame('Mon Site', $site->getName());
$this->assertSame(36, \strlen($site->getUuid()));
$this->assertSame(Website::TYPE_VITRINE, $site->getType());
$this->assertSame(Website::STATE_CREATED, $site->getState());
$this->assertInstanceOf(\DateTimeImmutable::class, $site->getCreatedAt());
$this->assertNull($site->getUpdatedAt());
}
public function testConstructorEcommerce(): void
{
$site = new Website($this->createCustomer(), 'Boutique', Website::TYPE_ECOMMERCE);
$this->assertSame(Website::TYPE_ECOMMERCE, $site->getType());
}
public function testSetters(): void
{
$site = new Website($this->createCustomer(), 'Test');
$site->setName('Nouveau nom');
$this->assertSame('Nouveau nom', $site->getName());
$site->setType(Website::TYPE_ECOMMERCE);
$this->assertSame(Website::TYPE_ECOMMERCE, $site->getType());
$now = new \DateTimeImmutable();
$site->setUpdatedAt($now);
$this->assertSame($now, $site->getUpdatedAt());
}
public function testState(): void
{
$site = new Website($this->createCustomer(), 'Test');
$this->assertFalse($site->isOpen());
$site->setState(Website::STATE_INSTALL_PROGRESS);
$this->assertSame(Website::STATE_INSTALL_PROGRESS, $site->getState());
$this->assertFalse($site->isOpen());
$site->setState(Website::STATE_OPEN);
$this->assertTrue($site->isOpen());
$this->assertInstanceOf(\DateTimeImmutable::class, $site->getUpdatedAt());
$site->setState(Website::STATE_SUSPENDED);
$this->assertFalse($site->isOpen());
$site->setState(Website::STATE_CLOSED);
$this->assertFalse($site->isOpen());
}
public function testUuidUnique(): void
{
$customer = $this->createCustomer();
$site1 = new Website($customer, 'Site 1');
$site2 = new Website($customer, 'Site 2');
$this->assertNotSame($site1->getUuid(), $site2->getUuid());
}
public function testRevendeurCode(): void
{
$site = new Website($this->createCustomer(), 'Test');
$this->assertNull($site->getRevendeurCode());
$result = $site->setRevendeurCode('REV01');
$this->assertSame('REV01', $site->getRevendeurCode());
$this->assertSame($site, $result);
$site->setRevendeurCode(null);
$this->assertNull($site->getRevendeurCode());
}
}