shouldReceive('getBuilderFromBasketOrFail') ->once() ->andReturn($builder); $orderTunnelService->shouldReceive('getShopForCustomer') ->once() ->with($shopperId) ->andReturn($shop); $orderTunnelService->shouldReceive('getAvailableTimeSlots') ->once() ->with($shop) ->andReturn($timeSlots); $orderTunnelService->shouldReceive('applyTimeSlot') ->once() ->with($builder, $shop, $timeslot, $timeSlots) ->andReturn($slot); $action = new ApplyPickTimeSlot($orderTunnelService); // WHEN $result = $action($input); // THEN expect($result->status)->toBe(ApplyPickTimeSlotStatus::MATCHED) ->and($result->timeSlot)->toBe($slot); }); it('returns unavailable output when no time slot matches', function (): void { // GIVEN $shopperId = new ShopperId(UuidHelper::v7()); $timeslot = CarbonImmutable::parse('2026-10-15'); $input = new ApplyPickTimeSlotInput( shopperId: $shopperId, timeslot: $timeslot, ); $builder = \Mockery::mock(OrderBuilderWithBasket::class); $shop = new Shop( id: new ShopId(UuidHelper::v7()), name: 'Shop 1', address: '1 rue Test', postcode: '75001', city: 'Paris', ); $timeSlots = []; $orderTunnelService = \Mockery::mock(OrderTunnelService::class); $orderTunnelService->shouldReceive('getBuilderFromBasketOrFail') ->once() ->andReturn($builder); $orderTunnelService->shouldReceive('getShopForCustomer') ->once() ->with($shopperId) ->andReturn($shop); $orderTunnelService->shouldReceive('getAvailableTimeSlots') ->once() ->with($shop) ->andReturn($timeSlots); $orderTunnelService->shouldReceive('applyTimeSlot') ->once() ->with($builder, $shop, $timeslot, $timeSlots) ->andReturnNull(); $action = new ApplyPickTimeSlot($orderTunnelService); // WHEN $result = $action($input); // THEN expect($result->status)->toBe(ApplyPickTimeSlotStatus::UNAVAILABLE) ->and($result->timeSlot)->toBeNull(); }); });