52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\App\Dto;
|
|
|
|
use App\Dto\IcsContentDto;
|
|
use Carbon\CarbonImmutable;
|
|
|
|
describe('IcsContentDto', function (): void {
|
|
it('can be instantiated with all properties', function (): void {
|
|
// GIVEN
|
|
$startsAt = CarbonImmutable::parse('2024-01-01 10:00:00');
|
|
$endsAt = CarbonImmutable::parse('2024-01-01 12:00:00');
|
|
|
|
// WHEN
|
|
$dto = new IcsContentDto(
|
|
uid: 'uid-123',
|
|
summary: 'My Event',
|
|
description: 'Event Description',
|
|
startsAt: $startsAt,
|
|
endsAt: $endsAt,
|
|
url: 'https://example.com'
|
|
);
|
|
|
|
// THEN
|
|
expect($dto->uid)->toBe('uid-123')
|
|
->and($dto->summary)->toBe('My Event')
|
|
->and($dto->description)->toBe('Event Description')
|
|
->and($dto->startsAt)->toBe($startsAt)
|
|
->and($dto->endsAt)->toBe($endsAt)
|
|
->and($dto->url)->toBe('https://example.com');
|
|
});
|
|
|
|
it('can be instantiated without optional url property', function (): void {
|
|
// GIVEN
|
|
$startsAt = CarbonImmutable::parse('2024-01-01 10:00:00');
|
|
$endsAt = CarbonImmutable::parse('2024-01-01 12:00:00');
|
|
|
|
// WHEN
|
|
$dto = new IcsContentDto(
|
|
uid: 'uid-456',
|
|
summary: 'My Event 2',
|
|
description: 'Event Description 2',
|
|
startsAt: $startsAt,
|
|
endsAt: $endsAt,
|
|
);
|
|
|
|
// THEN
|
|
expect($dto->url)->toBeNull();
|
|
});
|
|
});
|