47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Dto\PickupExceptionDto;
|
|
use App\Dto\ShopPickupExceptionPivotDto;
|
|
use Carbon\Carbon;
|
|
use Domain\Enums\RepeatFrequency;
|
|
|
|
describe('PickupExceptionDto', function () {
|
|
test('it can be instantiated with all properties', function () {
|
|
// GIVEN
|
|
$date = Carbon::parse('2026-05-01');
|
|
$pivot = new ShopPickupExceptionPivotDto(
|
|
replacement_date: Carbon::parse('2026-05-02'),
|
|
order_deadline_at: Carbon::parse('2026-05-01 18:00:00'),
|
|
);
|
|
|
|
// WHEN
|
|
$dto = new PickupExceptionDto(
|
|
id: '018f6c40-1234-7123-8123-123456789012',
|
|
date: $date,
|
|
label: '1er Mai',
|
|
repeatable: true,
|
|
repeat_frequency: RepeatFrequency::YEARLY,
|
|
auto_updated: false,
|
|
pivot: $pivot,
|
|
);
|
|
|
|
// THEN
|
|
expect($dto->id)->toBe('018f6c40-1234-7123-8123-123456789012')
|
|
->and($dto->label)->toBe('1er Mai')
|
|
->and($dto->repeatable)->toBeTrue()
|
|
->and($dto->repeat_frequency)->toBe(RepeatFrequency::YEARLY)
|
|
->and($dto->auto_updated)->toBeFalse()
|
|
->and($dto->pivot)->not->toBeNull()
|
|
->and($dto->getRouteKey())->toBe('018f6c40-1234-7123-8123-123456789012')
|
|
->and($dto->getRouteKeyName())->toBe('id')
|
|
->and($dto->resolveRouteBinding('some-id'))->toBeNull()
|
|
->and($dto->resolveChildRouteBinding('child', 'some-id', 'field'))->toBeNull();
|
|
|
|
$array = $dto->toArray();
|
|
expect($array)->toHaveKey('id', '018f6c40-1234-7123-8123-123456789012')
|
|
->and($array)->toHaveKey('label', '1er Mai')
|
|
->and($array)->toHaveKey('repeat_frequency', RepeatFrequency::YEARLY->value);
|
|
});
|
|
});
|