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>
This commit is contained in:
Serreau Jovann
2026-04-08 00:13:00 +02:00
parent 79c55ba0f9
commit 8bda02888c
29 changed files with 3347 additions and 5 deletions

View File

@@ -307,6 +307,39 @@ class PaymentReminderCommandTest extends TestCase
$this->assertSame(0, $tester->getStatusCode());
}
public function testFormalNoticeStepSendsEmailOnly(): void
{
// 32 days old -> formal_notice step (>= 31 days), all earlier steps done
$advert = $this->makeAdvert('04/2026-00001', 'client@example.com', 32);
$doneSteps = [
PaymentReminder::STEP_REMINDER_15,
PaymentReminder::STEP_WARNING_10,
PaymentReminder::STEP_SUSPENSION_WARNING_5,
PaymentReminder::STEP_FINAL_REMINDER_3,
PaymentReminder::STEP_SUSPENSION_1,
];
$this->stubReminderRepo($doneSteps, [$advert]);
$this->twig->method('render')->willReturn('<p>Email</p>');
$this->em->method('persist');
$this->em->method('flush');
// Expect 2 emails: client (mise en demeure) + admin notification
$this->mailer->expects($this->exactly(2))->method('sendEmail');
// No ActionService calls expected for formal_notice
$this->actionService->expects($this->never())->method('suspendCustomer');
$this->actionService->expects($this->never())->method('disableCustomer');
$this->actionService->expects($this->never())->method('markForDeletion');
$tester = new CommandTester($this->makeCommand());
$tester->execute([]);
$this->assertSame(0, $tester->getStatusCode());
$this->assertStringContainsString('1 relance(s) envoyee(s)', $tester->getDisplay());
}
public function testExceptionInStepIsLoggedAndContinues(): void
{
$advert = $this->makeAdvert('04/2026-00001', 'client@example.com', 20);

View File

@@ -39,4 +39,42 @@ class TestMailCommandTest extends TestCase
$this->assertStringContainsString('prod@test.com', $tester->getDisplay());
$this->assertStringContainsString('prod', $tester->getDisplay());
}
public function testForceDsnFailureReturnsFailure(): void
{
$mailer = $this->createStub(MailerService::class);
$twig = $this->createStub(Environment::class);
$twig->method('render')->willReturn('<html>test</html>');
$command = new TestMailCommand($mailer, $twig);
$tester = new CommandTester($command);
// An invalid DSN will throw an exception inside sendViaForceDsn -> returns FAILURE
$tester->execute([
'email' => 'test@test.com',
'--force-dsn' => 'invalid-dsn://this.will.fail',
]);
$this->assertSame(1, $tester->getStatusCode());
$this->assertStringContainsString('Echec envoi via force-dsn', $tester->getDisplay());
}
public function testForceDsnSuccessReturnsSuccess(): void
{
$mailer = $this->createStub(MailerService::class);
$twig = $this->createStub(Environment::class);
$twig->method('render')->willReturn('<html>test</html>');
$command = new TestMailCommand($mailer, $twig);
$tester = new CommandTester($command);
// Use the null transport DSN which succeeds without a real SMTP server
$tester->execute([
'email' => 'test@test.com',
'--force-dsn' => 'null://null',
]);
$this->assertSame(0, $tester->getStatusCode());
$this->assertStringContainsString('test@test.com', $tester->getDisplay());
}
}