'Strandweg 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE']; private Property $property; protected function setUp(): void { parent::setUp(); $this->travelTo(CarbonImmutable::parse('2026-10-22 10:00')); $this->seed([PropertySeeder::class, SiteSeeder::class]); $this->property = Property::sole(); Mail::fake(); Storage::fake('local'); Http::fake(['*' => Http::response('', 500)]); Content::save(['contract.terms' => '
Echte Bedingungen
', 'stay.cancellation' => 'Echtes Storno
']); Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051']); } public function test_a_complete_request_keeps_the_offer_hold_as_before(): void { $booking = $this->request(self::ADDRESS); $this->assertSame(Booking::HOLD_OFFER, $booking->hold_purpose); $this->assertTrue($booking->hold_expires_at->equalTo(now()->addHours(48))); } public function test_an_incomplete_request_gets_only_the_clarification_hold_of_its_mode(): void { $manual = $this->request(); $this->assertSame(Booking::HOLD_CLARIFICATION, $manual->hold_purpose); $this->assertTrue($manual->hold_expires_at->equalTo(now()->addMinutes(180)), 'release or manual request: 180 minutes'); $this->assertSame('active', $manual->clarificationState()['state']); Settings::tenant()->update(['process_defaults' => ['data_request_mode' => 'automatic']]); $automatic = $this->request(email: 'zwei@example.org', arrival: '2026-11-20', departure: '2026-11-23'); $this->assertTrue($automatic->hold_expires_at->equalTo(now()->addMinutes(15)), 'automatic request: 15 minutes'); } public function test_zero_means_no_clarification_hold_and_the_dates_stay_free(): void { Settings::tenant()->update(['process_defaults' => ['clarification_hold_manual_minutes' => 0]]); $booking = $this->request(); $this->assertNull($booking->hold_expires_at); $this->assertSame('none', $booking->clarificationState()['state']); $this->assertSame(BookingStatus::Reserved, $booking->status); $this->request(email: 'andere@example.org'); $this->assertSame(2, Booking::query()->count(), 'no hold: the same dates can still be requested'); } public function test_a_request_without_usable_email_is_not_held(): void { $booking = app(CreateReservation::class)->handle($this->property->fresh(), new StayRequest(CarbonImmutable::parse('2026-11-07'), CarbonImmutable::parse('2026-11-10'), 2), ['first_name' => 'Paul', 'last_name' => 'Telefon', 'email' => ''], source: 'phone', sendMails: false); $this->assertNull($booking->hold_expires_at); } public function test_an_expired_clarification_hold_leaves_the_request_open_and_the_offer_needs_free_dates(): void { $booking = $this->request(); $this->travel(181)->minutes(); app(ExpireReservations::class)->handle(); $booking->refresh(); $this->assertSame(BookingStatus::Reserved, $booking->status, 'the case stays open'); $this->assertSame('expired', $booking->clarificationState()['state']); $this->assertFalse(Booking::query()->occupying()->whereKey($booking->id)->exists(), 'the calendar is free again'); app(ContributeCaseFacts::class)->handle($booking, collect(self::ADDRESS)->mapWithKeys(fn (string $value, string $key): array => ['guest.'.$key => $value])->all(), FactSource::GuestLink, ['reference' => 'link-1']); $this->assertFalse($booking->fresh()->isHoldActive(), 'completing the details creates no offer hold by itself'); $this->assertSame(Booking::HOLD_CLARIFICATION, $booking->fresh()->hold_purpose); $competitor = $this->request(self::ADDRESS, email: 'schneller@example.org'); $this->assertSame(Booking::HOLD_OFFER, $competitor->hold_purpose); $this->expectException(ReservationException::class); app(SendOffer::class)->handle($booking->fresh()); } public function test_the_offer_turns_the_clarification_hold_into_the_unchanged_offer_hold(): void { $booking = $this->request(); app(ContributeCaseFacts::class)->handle($booking, collect(self::ADDRESS)->mapWithKeys(fn (string $value, string $key): array => ['guest.'.$key => $value])->all(), FactSource::GuestLink, ['reference' => 'link-1']); $offer = app(SendOffer::class)->handle($booking->fresh()); $this->assertSame(Booking::HOLD_OFFER, $offer->hold_purpose); $this->assertTrue($offer->hold_expires_at->equalTo(now()->addHours(48))); } public function test_a_binding_portal_booking_never_gets_a_clarification_hold(): void { $portal = Channel::factory()->for($this->property)->create(['name' => 'FeWo-direkt', 'booking_model' => 'portal_booking']); $booking = app(TakeOverExternalBooking::class)->handle($this->property, $portal, CarbonImmutable::parse('2026-12-05'), CarbonImmutable::parse('2026-12-08'), ['portal_reference' => 'HA-7']); $this->assertSame(BookingStatus::Confirmed, $booking->status); $this->assertNotSame(Booking::HOLD_CLARIFICATION, $booking->hold_purpose); $this->assertSame('none', $booking->clarificationState()['state']); } /** * Holds are set only by the existing reservation and offer steps (plus the intake decision of v0.11). Nothing of * the communication handler – data requests, answers, reminders, extraction – may extend or set one (CH-16/17). */ public function test_only_the_existing_reservation_steps_write_a_hold(): void { $allowed = [ 'Actions/ConfirmBooking.php', 'Actions/CreateReservation.php', 'Actions/DecideBookingWish.php', 'Actions/DeclineBooking.php', 'Actions/RejectOffer.php', 'Actions/ReleaseReservation.php', 'Actions/SendInformation.php', 'Actions/SendOffer.php', 'Actions/SetBookingStatus.php', 'Actions/TakeOverExternalBooking.php', 'Actions/TakeOverPortalInquiry.php', 'Documents/DocumentComposer.php', 'Filament/Resources/Bookings/Pages/ViewBooking.php', 'Models/Booking.php', 'Process/RequestHold.php', ]; $writers = []; $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(app_path(), \FilesystemIterator::SKIP_DOTS)); foreach ($files as $file) { $source = file_get_contents($file->getPathname()); if (preg_match("/'hold_expires_at' =>|hold_expires_at = |RequestHold::for/", $source)) { $writers[] = str_replace('\\', '/', substr($file->getPathname(), strlen(app_path()) + 1)); } } sort($writers); sort($allowed); $this->assertSame($allowed, $writers); } /** * @param array