Files

58 lines
2.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Process\Tester\Scenarios;
use App\Actions\ContributeCaseFacts;
use App\Enums\FactSource;
use App\Enums\IntakeKind;
use App\Process\Tester\SandboxContext;
/**
* S02/S03/S04/S05: a request without address – clarification hold and data request run side by side, the hold
* expires, the guest answers later (by link or by e-mail), the offer follows; finally the offer's deadline passes.
*/
final class MissingAddress extends Scenario
{
public static function key(): string
{
return 'missing_address';
}
public static function label(): string
{
return 'Fehlende Anschrift, späte Antwort';
}
public static function description(): string
{
return 'Die Anfrage kommt ohne Anschrift: Rückfrage beim Gast und Klärungsreservierung laufen nebeneinander, die Reservierung läuft ab, der Gast antwortet später.';
}
public static function intakes(): array
{
return [IntakeKind::Inquiry];
}
public static function inputs(): array
{
return [
...parent::inputs(),
'answer_after_hours' => ['label' => 'Antwort des Gastes nach (Stunden)', 'default' => 26, 'type' => 'int'],
'answer_by' => ['label' => 'Antwort über', 'default' => 'link', 'type' => 'select', 'options' => ['link' => 'Link im Formular', 'email' => 'E-Mail (ausgewertete Angaben)']],
];
}
public function events(array $inputs): array
{
return [
new ScenarioEvent('Gast fragt ohne Anschrift an', fn (SandboxContext $context) => $context->request([])),
new ScenarioEvent('Zwei Stunden vergehen (Klärungsfrist)', fn (SandboxContext $context) => $context->travel(125)),
new ScenarioEvent('Gast antwortet mit seiner Anschrift', function (SandboxContext $context) use ($inputs): void {
$context->travel(max(0, (int) ($inputs['answer_after_hours'] ?? 26) * 60 - 125));
app(ContributeCaseFacts::class)->handle($context->booking->fresh(), ['guest.street' => 'Teststraße 1', 'guest.postal_code' => '18225', 'guest.city' => 'Kühlungsborn', 'guest.country' => 'DE'], ($inputs['answer_by'] ?? 'link') === 'email' ? FactSource::Email : FactSource::GuestLink);
}),
new ScenarioEvent('Die Angebotsfrist vergeht ohne Annahme', fn (SandboxContext $context) => $context->travel(73 * 60)),
];
}
}