2026-06-14 21:32:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use App\Dto\IcsContentDto;
|
|
|
|
|
use App\Services\IcsGeneratorService;
|
|
|
|
|
use Carbon\CarbonImmutable;
|
|
|
|
|
|
|
|
|
|
it('generates a valid ICS string', function () {
|
2026-10-03 10:09:58 +02:00
|
|
|
// GIVEN
|
2026-06-14 21:32:07 +02:00
|
|
|
$service = new IcsGeneratorService('La Boutique de Cocotte');
|
|
|
|
|
|
|
|
|
|
// Fix time to ensure DTSTAMP doesn't fail assertion
|
|
|
|
|
CarbonImmutable::setTestNow(CarbonImmutable::create(2024, 1, 1, 10, 0, 0, 'UTC'));
|
|
|
|
|
|
|
|
|
|
$event = new IcsContentDto(
|
|
|
|
|
uid: 'test-uid@laboutiquedecocotte.fr',
|
|
|
|
|
summary: 'Test Event',
|
|
|
|
|
description: 'This is a test description with a comma, and a newline' . "\n",
|
|
|
|
|
startsAt: CarbonImmutable::create(2024, 1, 1, 12, 0, 0, 'Europe/Paris'),
|
|
|
|
|
endsAt: CarbonImmutable::create(2024, 1, 1, 12, 15, 0, 'Europe/Paris'),
|
|
|
|
|
url: 'https://laboutiquedecocotte.fr'
|
|
|
|
|
);
|
|
|
|
|
|
2026-10-03 10:09:58 +02:00
|
|
|
// WHEN
|
2026-06-14 21:32:07 +02:00
|
|
|
$ics = $service->generate($event);
|
|
|
|
|
|
2026-10-03 10:09:58 +02:00
|
|
|
// THEN
|
2026-06-14 21:32:07 +02:00
|
|
|
expect($ics)->toContain('BEGIN:VCALENDAR')
|
|
|
|
|
->toContain('VERSION:2.0')
|
|
|
|
|
->toContain('PRODID:-//La Boutique de Cocotte//NONSGML v1.0//EN')
|
|
|
|
|
->toContain('BEGIN:VEVENT')
|
|
|
|
|
->toContain('UID:test-uid@laboutiquedecocotte.fr')
|
|
|
|
|
->toContain('DTSTAMP:20240101T100000Z')
|
|
|
|
|
// 12:00 Europe/Paris in winter is 11:00 UTC
|
|
|
|
|
->toContain('DTSTART:20240101T110000Z')
|
|
|
|
|
->toContain('DTEND:20240101T111500Z')
|
|
|
|
|
->toContain('SUMMARY:Test Event')
|
|
|
|
|
->toContain('DESCRIPTION:This is a test description with a comma\, and a newline\n')
|
|
|
|
|
->toContain('URL:https://laboutiquedecocotte.fr')
|
|
|
|
|
->toContain('END:VEVENT')
|
|
|
|
|
->toContain('END:VCALENDAR');
|
|
|
|
|
});
|