$days */ function makeAssignment(array $days, bool $hasConstraint = true): array { $pc = ProfitCenter::factory()->create(); $supplier = Supplier::factory()->create([ 'hasDeliveryConstraint' => $hasConstraint, 'orderCutOffTime' => 12, 'deliveryLeadTime' => 48, // 2 nap ]); $schedule = DeliverySchedule::factory()->create($days); ProfitCenterSupplierSchedule::factory()->create([ 'profit_center_id' => $pc->id, 'supplier_id' => $supplier->id, 'delivery_schedule_id' => $schedule->id, ]); return [$pc, $supplier]; } const EVERY_DAY = [ 'monday' => true, 'tuesday' => true, 'wednesday' => true, 'thursday' => true, 'friday' => true, 'saturday' => true, 'sunday' => true, ]; const WEEKDAYS_ONLY = [ 'monday' => true, 'tuesday' => true, 'wednesday' => true, 'thursday' => true, 'friday' => true, ]; it('counts scheduled weekend days towards the lead time', function () { [$pc, $supplier] = makeAssignment(EVERY_DAY); $result = app(NextDeliveryDateCalculatorService::class) ->calculate($supplier->id, $pc->id, Carbon::parse('2026-04-17 08:00')); // Friday, cut-off előtt // Péntek (1.) + szombat (2.) telik el az átfutásból, így vasárnap már szállítható. expect($result?->toDateString())->toBe('2026-04-19'); // Sunday }); it('does not count weekends for a weekday-only schedule', function () { [$pc, $supplier] = makeAssignment(WEEKDAYS_ONLY); $result = app(NextDeliveryDateCalculatorService::class) ->calculate($supplier->id, $pc->id, Carbon::parse('2026-04-17 08:00')); // Friday, cut-off előtt // Péntek (1.) + hétfő (2.) telik el – a hétvége kimarad –, így kedd az első szállítási nap. expect($result?->toDateString())->toBe('2026-04-21'); // Tuesday }); it('returns a weekend day when there is no delivery constraint', function () { [$pc, $supplier] = makeAssignment(EVERY_DAY, hasConstraint: false); $result = app(NextDeliveryDateCalculatorService::class) ->calculate($supplier->id, $pc->id, Carbon::parse('2026-04-18 08:00')); // Saturday // Átfutási idő nélkül a szombat maga az első szállítási nap. expect($result?->toDateString())->toBe('2026-04-18'); // Saturday });