From b5b4288cc0e40ad43e2203a737c6caa4f1a92350 Mon Sep 17 00:00:00 2001 From: matthieu Date: Tue, 19 May 2026 23:32:29 +0200 Subject: [PATCH] feat(mail) : DTO MailSyncReport + test unitaire --- src/Mail/Dto/MailSyncReport.php | 24 +++++++++++ tests/Unit/Mail/MailSyncReportTest.php | 58 ++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/Mail/Dto/MailSyncReport.php create mode 100644 tests/Unit/Mail/MailSyncReportTest.php diff --git a/src/Mail/Dto/MailSyncReport.php b/src/Mail/Dto/MailSyncReport.php new file mode 100644 index 0000000..cee124b --- /dev/null +++ b/src/Mail/Dto/MailSyncReport.php @@ -0,0 +1,24 @@ + $errors + */ + public function __construct( + public int $createdCount, + public int $updatedCount, + public int $deletedCount, + public int $foldersScanned, + public array $errors, + public float $durationSeconds, + public DateTimeImmutable $startedAt, + public DateTimeImmutable $finishedAt, + ) {} +} diff --git a/tests/Unit/Mail/MailSyncReportTest.php b/tests/Unit/Mail/MailSyncReportTest.php new file mode 100644 index 0000000..bea5283 --- /dev/null +++ b/tests/Unit/Mail/MailSyncReportTest.php @@ -0,0 +1,58 @@ +createdCount); + self::assertSame(1, $report->updatedCount); + self::assertSame(0, $report->deletedCount); + self::assertSame(2, $report->foldersScanned); + self::assertSame([], $report->errors); + self::assertSame(5.0, $report->durationSeconds); + self::assertSame($start, $report->startedAt); + self::assertSame($finish, $report->finishedAt); + } + + public function testWithErrors(): void + { + $report = new MailSyncReport( + createdCount: 0, + updatedCount: 0, + deletedCount: 0, + foldersScanned: 1, + errors: ['IMAP connection timeout'], + durationSeconds: 0.5, + startedAt: new DateTimeImmutable(), + finishedAt: new DateTimeImmutable(), + ); + + self::assertCount(1, $report->errors); + self::assertSame('IMAP connection timeout', $report->errors[0]); + } +}