ldc-cocotte/tests/Unit/Domain/Models/ValueObjects/IcsContentTest.php
2026-11-16 14:18:42 +01:00

39 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Domain\Models\ValueObjects;
use Domain\Models\ValueObjects\IcsContent;
describe('IcsContent', function (): void {
it('creates a valid IcsContent value object and casts to string', function (): void {
// GIVEN
$raw = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nEND:VCALENDAR\r\n";
// WHEN
$ics = new IcsContent($raw);
// THEN
expect($ics->value)->toBe($raw)
->and((string) $ics)->toBe($raw);
});
it('rejects empty ICS content', function (): void {
// WHEN / THEN
expect(fn (): IcsContent => new IcsContent(' '))
->toThrow(\InvalidArgumentException::class);
});
it('rejects ICS content missing BEGIN:VCALENDAR header', function (): void {
// WHEN / THEN
expect(fn (): IcsContent => new IcsContent("BEGIN:VEVENT\r\nEND:VCALENDAR"))
->toThrow(\InvalidArgumentException::class);
});
it('rejects ICS content missing END:VCALENDAR footer', function (): void {
// WHEN / THEN
expect(fn (): IcsContent => new IcsContent("BEGIN:VCALENDAR\r\nBEGIN:VEVENT"))
->toThrow(\InvalidArgumentException::class);
});
});