timeslotList)->toBe([]); }); it('returns available PickupTimeSlot instances up to 28 days for an active shop', function (): void { // GIVEN $now = CarbonImmutable::parse('2026-06-15 10:00:00'); CarbonImmutable::setTestNow($now); $shop = new Shop(); $shop->name = 'Boutique Active'; $shop->address = '10 rue Principale'; $shop->postcode = '75001'; $shop->city = 'Paris'; $shop->default = true; $shop->save(); $query = new GetAvailableTimeslotsQuery( new PickupSchedulingService(new EloquentPickupExceptionRepository()), new EloquentShopRepository(), ); $input = new GetAvailableTimeslotsQueryInput(new ShopId(UuidHelper::fromString($shop->id))); // WHEN $result = $query($input); // THEN $maxDate = $now->addDays(28); expect($result->timeslotList)->not->toBeEmpty(); foreach ($result->timeslotList as $slot) { expect($slot->getAt()->getTimestamp())->toBeLessThanOrEqual($maxDate->getTimestamp()); } }); it('respects pickup exceptions attached to the shop', function (): void { // GIVEN CarbonImmutable::setTestNow('2026-06-15 10:00:00'); $shop = new Shop(); $shop->name = 'Boutique Exception'; $shop->address = '10 rue Principale'; $shop->postcode = '75001'; $shop->city = 'Paris'; $shop->default = true; $shop->save(); $exception = new PickupException(); $exception->date = Carbon::parse('2026-06-19'); $exception->label = 'Fermeture exceptionnelle'; $exception->repeatable = false; $exception->repeat_frequency = RepeatFrequency::YEARLY; $exception->auto_updated = false; $exception->save(); $shop->pickupExceptions()->attach($exception->id, [ 'replacement_date' => '2026-06-20', 'order_deadline_at' => '2026-06-18 12:00:00', ]); $query = new GetAvailableTimeslotsQuery( new PickupSchedulingService(new EloquentPickupExceptionRepository()), new EloquentShopRepository(), ); $input = new GetAvailableTimeslotsQueryInput(new ShopId(UuidHelper::fromString($shop->id))); // WHEN $result = $query($input); // THEN $dates = array_map( static fn (PickupTimeSlot $slot): string => $slot->getAt()->format('Y-m-d'), $result->timeslotList, ); expect($dates)->not->toContain('2026-06-19') ->and($dates)->toContain('2026-06-20'); }); it('throws InvalidArgumentException when invalid input is passed', function (): void { // GIVEN $query = new GetAvailableTimeslotsQuery( new PickupSchedulingService(new EloquentPickupExceptionRepository()), new EloquentShopRepository(), ); $invalidInput = new class () implements QueryInput { }; // WHEN & THEN expect( /** @phpstan-ignore argument.type */ fn () => $query($invalidInput) )->toThrow(\InvalidArgumentException::class); }); });