ldc-boutique-cnc-sable/tests/Unit/Domain/Models/Entities/PickupExceptionOnDateTest.php
Jérémy Munsch c40016bba1
feat(order): implement order placement and related DTOs
- Add methods to convert OrderLine and DeliveryAddress to DTOs.
- Introduce toPlacedEvent method in Order to generate domain event.
- Enhance OrderUnit with Regate code mapping.
- Implement tests for new functionality and ensure correctness.
2026-10-29 20:35:13 +01:00

70 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Domain\Models\Entities;
use Carbon\CarbonImmutable;
use Domain\Enums\RepeatFrequency;
use Domain\Models\Entities\PickupExceptionOnDate;
use Domain\Models\ValueObjects\Entities\PickupExceptionId;
use Ramsey\Uuid\Uuid;
describe('PickupExceptionOnDate', function (): void {
it('can instantiate correctly', function (): void {
// GIVEN
$id = new PickupExceptionId(Uuid::uuid7());
$date = CarbonImmutable::now();
$label = 'Férié';
$repeatable = true;
$repeatFrequency = RepeatFrequency::YEARLY;
$autoUpdated = false;
// WHEN
$entity = new PickupExceptionOnDate(
$id,
$date,
$label,
$repeatable,
$repeatFrequency,
$autoUpdated
);
// THEN
expect($entity->id())->toBe($id)
->and($entity->id)->toBe($id)
->and($entity->date)->toBe($date)
->and($entity->label)->toBe($label)
->and($entity->repeatable)->toBe($repeatable)
->and($entity->repeatFrequency)->toBe($repeatFrequency)
->and($entity->autoUpdated)->toBe($autoUpdated);
});
it('determines if exception falls on a pickup day', function (): void {
// GIVEN
$fridayDate = CarbonImmutable::create(2025, 1, 3); // 2025-01-03 is Friday
$mondayDate = CarbonImmutable::create(2025, 1, 6); // 2025-01-06 is Monday
$fridayException = new PickupExceptionOnDate(
new PickupExceptionId(Uuid::uuid7()),
$fridayDate,
'Friday holiday',
false,
RepeatFrequency::YEARLY,
false
);
$mondayException = new PickupExceptionOnDate(
new PickupExceptionId(Uuid::uuid7()),
$mondayDate,
'Monday holiday',
false,
RepeatFrequency::YEARLY,
false
);
// WHEN & THEN
expect($fridayException->isPickupDay())->toBeTrue()
->and($mondayException->isPickupDay())->toBeFalse();
});
});