travelTo(CarbonImmutable::parse('2026-10-23 18:00')); $this->seed([PropertySeeder::class, SiteSeeder::class]); $this->property = Property::sole(); Storage::fake('local'); Storage::fake('public'); Content::save(['contract.terms' => '
Echte Bedingungen
', 'stay.cancellation' => 'Echtes Storno
']); config(['mail.default' => 'array', 'fewo.spam.min_seconds' => 0]); Mail::swap(new MailManager($this->app)); Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'test@example.org']); Http::preventStrayRequests(); Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic', 'clarification_hold_auto_minutes' => 120, 'data_request_mode' => 'automatic']]); } public function test_frozen_cases_keep_their_contract_values_activities_and_automation_decision(): void { $path = base_path('tests/Fixtures/process/ongoing/cases.json'); if (env('PROCESS_ONGOING_RECORD')) { $this->record($path); $this->markTestIncomplete('Ongoing cases recorded.'); } $this->assertFileExists($path); $cases = json_decode((string) file_get_contents($path), true); $this->restore($cases); $this->travelTo(CarbonImmutable::parse(self::NOW)); foreach ($cases as $label => $case) { $booking = Booking::query()->findOrFail($case['id']); $this->assertSame($case['expected'], $this->derive($booking), "Derived values of {$label} changed."); $before = $this->contract($booking); app(CaseAutomation::class)->advance($booking->fresh()); $this->assertSame($before, $this->contract($booking->fresh()), "Advancing {$label} changed its contract data."); } } private function record(string $path): void { $address = ['street' => 'Lindenallee 12', 'postal_code' => '10115', 'city' => 'Berlin', 'country' => 'DE']; $cases = []; $cases['a1_clarification'] = $this->request('2026-11-07', '2026-11-10', 'klaer@example.org', []); $cases['a1_offer_sent'] = $this->request('2026-11-14', '2026-11-17', 'angebot@example.org', $address); $confirmed = $this->request('2026-12-01', '2026-12-08', 'fest@example.org', $address); app(AcceptOffer::class)->handle($confirmed->fresh(), $confirmed->fresh()->offer_version); $cases['a1_confirmed_deposit_open'] = $confirmed; $paid = $this->request('2026-11-18', '2026-11-21', 'bezahlt@example.org', $address); app(AcceptOffer::class)->handle($paid->fresh(), $paid->fresh()->offer_version); app(RecordPayment::class)->handle($paid->fresh(), (int) $paid->fresh()->deposit, now()); $cases['a1_deposit_paid'] = $paid; $cancelled = $this->request('2026-12-10', '2026-12-13', 'storno@example.org', $address); app(AcceptOffer::class)->handle($cancelled->fresh(), $cancelled->fresh()->offer_version); app(CancelBooking::class)->handle($cancelled->fresh(), reason: 'Gast verhindert'); $cases['a1_cancelled'] = $cancelled; $past = $this->request('2026-10-26', '2026-10-30', 'vorbei@example.org', $address); app(AcceptOffer::class)->handle($past->fresh(), $past->fresh()->offer_version); $cases['a1_stay_over'] = $past; $fewo = $this->channel('FeWo-direkt', 'mixed', ['booking' => ['payments' => 'portal']]); $inquiry = app(TakeOverPortalInquiry::class)->handle($fewo, CarbonImmutable::parse('2027-03-01'), CarbonImmutable::parse('2027-03-05'), 'HA-ANF'); $cases['a2_inquiry'] = $inquiry; $ds = $this->channel('Destination Solutions', 'portal_booking'); $a3 = app(TakeOverExternalBooking::class)->handle($this->property, $ds, CarbonImmutable::parse('2027-04-01'), CarbonImmutable::parse('2027-04-08'), ['portal_reference' => 'DS-1', 'portal_total' => 98000, 'guests' => 2]); $cases['a3_booking'] = $a3; $a4 = app(TakeOverExternalBooking::class)->handle($this->property, $fewo, CarbonImmutable::parse('2027-07-10'), CarbonImmutable::parse('2027-07-17'), ['portal_reference' => 'HA-A4', 'portal_total' => 97951, 'guests' => 2]); app(RecordPortalAmounts::class)->handle($a4->fresh(), null, [['kind' => 'payout_announced', 'amount' => 89469]], [['amount' => 39061, 'paid_on' => '2026-10-23']], 'FeWo-direkt'); $cases['a4_portal_payments'] = $a4; $a5channel = $this->channel('Portal A5', 'portal_booking', ['booking' => ['payments' => 'portal', 'documents' => 'portal', 'guest_messages' => 'portal']]); $cases['a5_booking'] = app(TakeOverExternalBooking::class)->handle($this->property, $a5channel, CarbonImmutable::parse('2027-05-01'), CarbonImmutable::parse('2027-05-04'), ['portal_reference' => 'P5-1', 'portal_total' => 60000]); $cases['a6_private'] = app(CreateInternalCase::class)->handle($this->property, InternalKind::PrivateStay, CarbonImmutable::parse('2027-06-01'), CarbonImmutable::parse('2027-06-04'), ['occasion' => 'Familie']); $migrated = $this->request('2026-11-24', '2026-11-27', 'alt@example.org', $address); $migrated->forceFill(['profile' => [...(array) $migrated->fresh()->profile, 'origin' => 'migration']])->saveQuietly(); $cases['legacy_migration_offer'] = $migrated; $this->travelTo(CarbonImmutable::parse(self::NOW)); $out = []; foreach ($cases as $label => $booking) { $booking = $booking->fresh(); $out[$label] = ['id' => $booking->id, 'rows' => $this->rows($booking), 'expected' => $this->derive($booking)]; } @mkdir(dirname($path), 0777, true); file_put_contents($path, json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)."\n"); } /** * @return array