travelTo(CarbonImmutable::parse('2026-10-23 18:00')); $this->seed([PropertySeeder::class, SiteSeeder::class]); $this->property = Property::sole(); Storage::fake('local'); Content::save(['contract.terms' => '

Echte Bedingungen

', 'stay.cancellation' => '

Echtes Storno

']); config(['mail.default' => 'array']); Mail::swap(new MailManager($this->app)); Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'test@example.org', 'process_defaults' => ['processing' => 'automatic']]); Http::preventStrayRequests(); $this->portal = Channel::factory()->for($this->property)->create(['name' => 'Destination Solutions', 'booking_model' => 'portal_booking', 'import_enabled' => false, 'settings' => ['import_url' => 'https://ds.example/a.ics', 'email_senders' => 'ds.example']]); } public function test_documents_wait_while_a_cancellation_report_is_open_and_go_after_clarification(): void { $booking = app(TakeOverExternalBooking::class)->handle($this->property, $this->portal, CarbonImmutable::parse('2026-12-05'), CarbonImmutable::parse('2026-12-12'), ['portal_reference' => 'DS-9', 'portal_total' => 98000, 'guests' => 2]); $task = $this->report($booking); app(ContributeCaseFacts::class)->handle($booking->fresh(), ['guest.first_name' => 'Dora', 'guest.last_name' => 'Gast', 'guest.email' => 'dora@example.org'], FactSource::PortalMail); $booking->refresh(); $this->assertNull($booking->confirmation_sent_at, 'no documents while the report is open'); $this->assertSame(BookingStatus::Confirmed, $booking->status, 'the report never changes the booking'); $held = app(CaseAutomation::class)->advance($booking->fresh()); $this->assertSame([OutwardSuspension::reason($booking)], $held, 'the documents wait only for the clarification'); $task->update(['status' => BookingTaskStatus::Done, 'completed_at' => now(), 'note' => 'Portal bestätigt: keine Stornierung']); $held = app(CaseAutomation::class)->advance($booking->fresh()); // After clarification the step is evaluated from the case's current state again: here the documents' own // release rules (portal template, released texts) decide, no longer the report. $this->assertNotContains(OutwardSuspension::reason($booking), $held); $this->assertStringContainsString('Arbeitsfassung', implode(' ', $held)); } public function test_arrival_information_waits_but_internal_tasks_go_on(): void { $booking = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'arrival' => now()->addDays(2)->toDateString(), 'departure' => now()->addDays(6)->toDateString(), 'deposit_due_on' => now()->subDay()->toDateString(), 'confirmed_at' => now()]); $this->report($booking); app(SendBookingReminders::class)->handle(); $this->assertNull($booking->fresh()->arrival_info_sent_at); $this->assertTrue(BookingTask::query()->where('booking_id', $booking->id)->where('kind', BookingTaskKind::DepositReminder)->exists(), 'internal tasks are not blocked'); } public function test_an_unassigned_portal_mail_suspends_nothing(): void { $booking = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'arrival' => now()->addDays(2)->toDateString(), 'departure' => now()->addDays(6)->toDateString(), 'confirmed_at' => now()]); app(ProcessPortalMail::class)->handle(new PortalMail('', 'noreply@ds.example', 'Buchung storniert: UNBEKANNT-1', 'Die Buchung vom 01.03.2027 bis 05.03.2027 wurde storniert.', CarbonImmutable::now())); app(SendBookingReminders::class)->handle(); $this->assertNull(OutwardSuspension::reason($booking)); $this->assertNotNull($booking->fresh()->arrival_info_sent_at); } private function report(Booking $booking): BookingTask { return BookingTask::query()->create(['booking_id' => $booking->id, 'kind' => BookingTaskKind::PortalCancellationReported, 'status' => BookingTaskStatus::Open, 'title' => 'Portal meldet Stornierung']); } }