59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Unit\Mail;
|
|
|
|
use App\Mail\Dto\MailSyncReport;
|
|
use DateTimeImmutable;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
class MailSyncReportTest extends TestCase
|
|
{
|
|
public function testInstantiationWithDefaults(): void
|
|
{
|
|
$start = new DateTimeImmutable('2026-01-01 10:00:00');
|
|
$finish = new DateTimeImmutable('2026-01-01 10:00:05');
|
|
|
|
$report = new MailSyncReport(
|
|
createdCount: 3,
|
|
updatedCount: 1,
|
|
deletedCount: 0,
|
|
foldersScanned: 2,
|
|
errors: [],
|
|
durationSeconds: 5.0,
|
|
startedAt: $start,
|
|
finishedAt: $finish,
|
|
);
|
|
|
|
self::assertSame(3, $report->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]);
|
|
}
|
|
}
|