true, 'booking.whole_vehicle_enabled' => true, ]); $service = new BookingService; foreach (VehicleOption::cases() as $option) { expect(fn () => $service->validateSelections([new VehicleSelectionData($option)])) ->not->toThrow(InvalidVehicleSelectionException::class); } }); test('front seat and back seat can be selected together in one booking', function () { config(['booking.back_seat_enabled' => true]); $service = new BookingService; expect(fn () => $service->validateSelections([ new VehicleSelectionData(VehicleOption::FrontSeat, 1), new VehicleSelectionData(VehicleOption::BackSeat, 2), ]))->not->toThrow(InvalidVehicleSelectionException::class); }); test('requesting more front seats than the configured max is rejected', function () { config(['booking.front_seat_max_per_booking' => 1]); $service = new BookingService; expect(fn () => $service->validateSelections([new VehicleSelectionData(VehicleOption::FrontSeat, 2)])) ->toThrow(InvalidVehicleSelectionException::class); }); test('requesting front seats up to the configured max passes', function () { config(['booking.front_seat_max_per_booking' => 2]); $service = new BookingService; expect(fn () => $service->validateSelections([new VehicleSelectionData(VehicleOption::FrontSeat, 2)])) ->not->toThrow(InvalidVehicleSelectionException::class); }); test('back seat is rejected when disabled via config', function () { config(['booking.back_seat_enabled' => false]); $service = new BookingService; expect(fn () => $service->validateSelections([new VehicleSelectionData(VehicleOption::BackSeat)])) ->toThrow(InvalidVehicleSelectionException::class); }); test('whole vehicle is rejected when disabled via config', function () { config(['booking.whole_vehicle_enabled' => false]); $service = new BookingService; expect(fn () => $service->validateSelections([new VehicleSelectionData(VehicleOption::WholeVehicle)])) ->toThrow(InvalidVehicleSelectionException::class); }); test('the same vehicle option cannot be selected twice in one booking', function () { config(['booking.back_seat_enabled' => true]); $service = new BookingService; expect(fn () => $service->validateSelections([ new VehicleSelectionData(VehicleOption::BackSeat, 1), new VehicleSelectionData(VehicleOption::BackSeat, 1), ]))->toThrow(InvalidVehicleSelectionException::class); }); test('whole vehicle cannot be combined with another vehicle option', function () { config([ 'booking.back_seat_enabled' => true, 'booking.whole_vehicle_enabled' => true, ]); $service = new BookingService; expect(fn () => $service->validateSelections([ new VehicleSelectionData(VehicleOption::WholeVehicle), new VehicleSelectionData(VehicleOption::BackSeat), ]))->toThrow(InvalidVehicleSelectionException::class); });