58 lines
2.2 KiB
PHP
58 lines
2.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Tests\Unit\Infra\Mail;
|
||
|
|
|
||
|
|
use Infra\Mail\ClientSecurityAlertMail;
|
||
|
|
use Infra\Mail\SecurityAlertDetails;
|
||
|
|
use Ramsey\Uuid\Uuid;
|
||
|
|
|
||
|
|
covers(ClientSecurityAlertMail::class);
|
||
|
|
|
||
|
|
describe('ClientSecurityAlertMail Unit Tests', function (): void {
|
||
|
|
it('builds email envelope with correct subject', function (): void {
|
||
|
|
// GIVEN
|
||
|
|
$mail = new ClientSecurityAlertMail(
|
||
|
|
eventType: 'Client Secret Generated',
|
||
|
|
clientId: Uuid::fromString('01917b2f-7f41-7654-8c88-66280be01234'),
|
||
|
|
clientIdentifier: 'arcadia_id_testclient',
|
||
|
|
occurredAt: new \DateTimeImmutable('2026-08-21 10:00:00 UTC'),
|
||
|
|
details: SecurityAlertDetails::empty(),
|
||
|
|
);
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$envelope = $mail->envelope();
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($envelope->subject)->toBe('[Arcadia Security] Client Secret Generated for arcadia_id_testclient');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('builds email content with correct markdown view and typed details', function (): void {
|
||
|
|
// GIVEN
|
||
|
|
$clientId = Uuid::fromString('01917b2f-7f41-7654-8c88-66280be01234');
|
||
|
|
$details = SecurityAlertDetails::forStatusToggled(false);
|
||
|
|
$occuredAt = new \DateTimeImmutable('2026-08-21 10:00:00 UTC');
|
||
|
|
$mail = new ClientSecurityAlertMail(
|
||
|
|
eventType: 'Client Status Changed (Deactivated)',
|
||
|
|
clientId: $clientId,
|
||
|
|
clientIdentifier: 'arcadia_id_testclient',
|
||
|
|
occurredAt: $occuredAt,
|
||
|
|
details: $details,
|
||
|
|
);
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$content = $mail->content();
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($content->markdown)->toBe('mails.security-alert')
|
||
|
|
->and($content->with['eventType'])->toBe('Client Status Changed (Deactivated)')
|
||
|
|
->and($content->with['clientIdentifier'])->toBe('arcadia_id_testclient')
|
||
|
|
->and($content->with['clientId'])->toBe($clientId)
|
||
|
|
->and($content->with['occurredAt'])->toBe($occuredAt)
|
||
|
|
->and($content->with['details'])->toBe($details)
|
||
|
|
->and($content->with['details']->isActive)->toBeFalse()
|
||
|
|
->and($content->with['details']->description)->toBe('Client account suspended');
|
||
|
|
});
|
||
|
|
});
|