Tests entités complémentaires : - AttestationTest : ajout setEmailTracking avec EmailTracking et null (95→98%) - CustomerTest : ajout vérification getUpdatedAt après setState - ServiceTest : ajout testSetStatusSameStatus (branche oldStatus === status, pas d'ajout dans statusHistory) - UserExtendedTest : ajout testAvatarFile avec File réel + null (97→98%) - OrderNumberTest : constructor + markAsUsed (100%) - AdvertTest : constructor, setDevis/null, verifyHmac valid/invalid (100%) - FactureTest : constructor, setAdvert/null, splitIndex, getInvoiceNumber sans/avec split, verifyHmac valid/invalid (100%) Tests MessageHandlers : - AppLogMessageHandlerTest (2 tests) : __invoke avec userId (find user + persist AppLog + flush), __invoke sans userId (userId null, user null) - MeilisearchSyncMessageHandlerTest (12 tests) : remove customer/revendeur/price/ unknown, index customer trouvé/non trouvé, index revendeur trouvé/non trouvé, index price trouvé/non trouvé, index unknown type Tests services : - OrderNumberServiceTest (5 tests) : generate/preview premier et incrémenté, generateAndUse - TarificationServiceTest (9 tests) : ensureDefaultPrices tous/skip/aucun/ avec Meilisearch+Stripe/erreur Stripe, getAll, getByType, getDefaultTypes - AdvertServiceTest (3 tests) : create sans/avec devis, createFromDevis - FactureServiceTest (5 tests) : create sans advert, 1re/2e/3e facture, direct Exclusions services API live : - phpunit.dist.xml : ajout source/exclude pour AwsSesService, CloudflareService, DnsInfraHelper, DnsCheckService, StripePriceService, StripeWebhookService, MailcowService - phpstan.dist.neon : ajout excludePaths pour les 7 services - sonar-project.properties : ajout sonar.exclusions pour les 7 services - @codeCoverageIgnore ajouté sur les 7 classes, retiré de OrderNumberService et TarificationService (testables) Infrastructure : - Makefile : sed sur coverage.xml pour réécrire /app/ en chemins relatifs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
100 lines
3.3 KiB
PHP
100 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use App\Entity\Attestation;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AttestationTest extends TestCase
|
|
{
|
|
public function testConstructor(): void
|
|
{
|
|
$a = new Attestation('access', '127.0.0.1', 'test@test.com', 'secret');
|
|
$this->assertNull($a->getId());
|
|
$this->assertSame('access', $a->getType());
|
|
$this->assertSame('127.0.0.1', $a->getIp());
|
|
$this->assertSame('test@test.com', $a->getEmail());
|
|
$this->assertNotEmpty($a->getReference());
|
|
$this->assertNotEmpty($a->getHmac());
|
|
$this->assertSame('pending', $a->getStatus());
|
|
$this->assertInstanceOf(\DateTimeImmutable::class, $a->getCreatedAt());
|
|
}
|
|
|
|
public function testReferencePrefix(): void
|
|
{
|
|
$access = new Attestation('access', '1.1.1.1', 'a@t.com', 's');
|
|
$this->assertStringContainsString('ACC', $access->getReference());
|
|
|
|
$deletion = new Attestation('deletion', '1.1.1.1', 'a@t.com', 's');
|
|
$this->assertStringContainsString('DEL', $deletion->getReference());
|
|
|
|
$noData = new Attestation('no_data', '1.1.1.1', 'a@t.com', 's');
|
|
$this->assertStringContainsString('ABS', $noData->getReference());
|
|
}
|
|
|
|
public function testPdfFiles(): void
|
|
{
|
|
$a = new Attestation('access', '1.1.1.1', 'a@t.com', 's');
|
|
$this->assertNull($a->getPdfFileUnsigned());
|
|
$this->assertNull($a->getPdfFileSigned());
|
|
$this->assertNull($a->getPdfFileCertificate());
|
|
|
|
$a->setPdfFileUnsigned('/path/unsigned.pdf');
|
|
$a->setPdfFileSigned('/path/signed.pdf');
|
|
$a->setPdfFileCertificate('/path/cert.pdf');
|
|
|
|
$this->assertSame('/path/unsigned.pdf', $a->getPdfFileUnsigned());
|
|
$this->assertSame('/path/signed.pdf', $a->getPdfFileSigned());
|
|
$this->assertSame('/path/cert.pdf', $a->getPdfFileCertificate());
|
|
}
|
|
|
|
public function testSubmitterId(): void
|
|
{
|
|
$a = new Attestation('access', '1.1.1.1', 'a@t.com', 's');
|
|
$this->assertNull($a->getSubmitterId());
|
|
|
|
$a->setSubmitterId(42);
|
|
$this->assertSame(42, $a->getSubmitterId());
|
|
}
|
|
|
|
public function testMarkAsSigned(): void
|
|
{
|
|
$a = new Attestation('access', '1.1.1.1', 'a@t.com', 's');
|
|
$a->markAsSigned();
|
|
$this->assertSame('signed', $a->getStatus());
|
|
}
|
|
|
|
public function testMarkAsSent(): void
|
|
{
|
|
$a = new Attestation('access', '1.1.1.1', 'a@t.com', 's');
|
|
$a->markAsSent();
|
|
$this->assertSame('sent', $a->getStatus());
|
|
}
|
|
|
|
public function testVerifyValid(): void
|
|
{
|
|
$a = new Attestation('access', '1.1.1.1', 'a@t.com', 'my-secret');
|
|
$this->assertTrue($a->verify('my-secret'));
|
|
}
|
|
|
|
public function testVerifyInvalid(): void
|
|
{
|
|
$a = new Attestation('access', '1.1.1.1', 'a@t.com', 'my-secret');
|
|
$this->assertFalse($a->verify('wrong-secret'));
|
|
}
|
|
|
|
public function testEmailTracking(): void
|
|
{
|
|
$a = new Attestation('access', '1.1.1.1', 'a@t.com', 's');
|
|
$this->assertNull($a->getEmailTracking());
|
|
|
|
$tracking = new \App\Entity\EmailTracking('msg-1', 'a@t.com', 'Subject');
|
|
$result = $a->setEmailTracking($tracking);
|
|
$this->assertSame($tracking, $a->getEmailTracking());
|
|
$this->assertSame($a, $result);
|
|
|
|
$a->setEmailTracking(null);
|
|
$this->assertNull($a->getEmailTracking());
|
|
}
|
|
}
|