travelTo(CarbonImmutable::parse('2026-10-23 10:00')); $this->seed([PropertySeeder::class, SiteSeeder::class]); $this->property = Property::sole(); Mail::fake(); } /** Case H: the optional address check sits at an extension point; only the A1 offer model offers the variant. */ public function test_case_h_an_optional_address_check_is_added_at_an_extension_point_without_changing_other_models(): void { $catalogue = app(ProcessCatalogue::class); $using = array_keys(array_filter($catalogue->models(), fn ($model): bool => collect($model->variants())->contains(fn ($variant): bool => in_array('guest.address_check', $model->modules($variant->key), true)))); $this->assertSame(['a1.offer', 'inquiry.request'], $using, 'the former offer model and the request base process that replaces it'); $this->assertSame([], $catalogue->problems()); foreach ($catalogue->models() as $key => $model) { $this->assertNotContains('guest.address_check', $model->modules('standard'), "{$key}: standard course unchanged"); } $booking = $this->request(postalCode: '1011'); $plan = ProcessPlan::freeze($booking->process(), ['model' => 'a1.offer', 'variant' => 'address_check'], sandbox: true); $booking->forceFill(['profile' => [...$booking->profile, 'plan' => $plan->toArray()]])->saveQuietly(); $check = collect(CaseActivities::for($booking->fresh()))->firstWhere('key', 'address_check'); $this->assertSame(ActivityState::Done, $check->state, 'the check only informs and holds nothing back'); $this->assertStringContainsString('Postleitzahl hat nicht fünf Ziffern', $check->detail); } public function test_case_h_the_address_check_cannot_reach_a_real_case(): void { $this->expectExceptionMessage('nur im Prozess-Tester'); ProcessPlan::freeze($this->request()->process(), ['model' => 'a1.offer', 'variant' => 'address_check']); } /** Case G: the clarification hold stands while the missing details are collected; the offer waits for them, not for the hold. */ public function test_case_g_hold_and_data_collection_run_independently_and_the_offer_waits_for_the_details(): void { $booking = $this->request(street: ''); $activities = collect(CaseActivities::for($booking->fresh()))->keyBy('key'); $this->assertTrue(Booking::query()->occupying()->whereKey($booking->id)->exists(), 'the dates are held at once, independent of the missing details'); $this->assertSame(ActivityState::Open, $activities['contact']->state); $this->assertStringContainsString('fehlt: Straße und Hausnummer', $activities['contact']->detail); $this->assertSame(ActivityState::Later, $activities['offer']->state, 'no binding offer before the required details'); $this->assertSame('erst wenn alle Angaben da sind', $activities['offer']->detail); } private function request(string $street = 'Weg 1', string $postalCode = '10115'): Booking { return app(CreateReservation::class)->handle($this->property->fresh(), new StayRequest(CarbonImmutable::parse('2026-11-07'), CarbonImmutable::parse('2026-11-10'), 2), ['first_name' => 'Gesa', 'last_name' => 'Gast', 'email' => 'gesa@example.org', 'street' => $street, 'postal_code' => $postalCode, 'city' => 'Berlin', 'country' => 'DE'])->fresh(); } }