V2.1: Tester-Szenarien Portalbestätigung, Nachricht über anderes Medium, allgemeine Frage

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-05 08:02:52 +01:00
1 parent 8026eceab4
commit f8561fe0e5
6 files changed
+235 -2

No files matched your search

@@ -0,0 +1,63 @@
<?php
namespace App\Process\Tester\Scenarios;
use App\Communication\IncomingMessage;
use App\Communication\MessageIntake;
use App\Enums\IntakeKind;
use App\Enums\Medium;
use App\Process\Tester\SandboxContext;
use Carbon\CarbonImmutable;
/**
* V2.1: a message of a guest arrives through another medium (WhatsApp or chat; no provider, only the entry). Shows how
* medium, reference and rules decide – assigned reply, unassignable message, contradictory reference – and that nothing
* is taken over or created by itself.
*/
final class MessageOtherMedium extends Scenario
{
public static function key(): string
{
return 'message_other_medium';
}
public static function label(): string
{
return 'Nachricht über WhatsApp oder Chat';
}
public static function description(): string
{
return 'Der Gast antwortet in einem anderen Medium – mit überprüftem Bezug, ohne Bezug oder mit widersprüchlicher Vorgangsnummer. Zeigt Zuordnung, Absicht und erlaubte Wirkung.';
}
public static function intakes(): array
{
return [IntakeKind::Inquiry, IntakeKind::Booking];
}
public static function inputs(): array
{
return [
...parent::inputs(),
'medium' => ['label' => 'Medium', 'default' => 'whatsapp', 'type' => 'select', 'options' => ['whatsapp' => 'WhatsApp', 'chat' => 'Chat']],
'reference' => ['label' => 'Bezug', 'default' => 'verified', 'type' => 'select', 'options' => ['verified' => 'überprüfter Bezug zum Vorgang', 'none' => 'kein Bezug (nur Absender)', 'contradicting' => 'überprüfter Bezug, Text nennt andere Nummer']],
'consent' => ['label' => 'Einwilligung des Gastes liegt vor', 'default' => true, 'type' => 'bool'],
];
}
public function events(array $inputs): array
{
return [
new ScenarioEvent('Anfrage des Gastes liegt vor', fn (SandboxContext $context) => $context->request([])),
new ScenarioEvent('Nachricht des Gastes im anderen Medium', function (SandboxContext $context) use ($inputs): void {
$reference = (string) ($inputs['reference'] ?? 'verified');
$text = 'Wir kommen am Anreisetag gegen 16 Uhr an.'.($reference === 'contradicting' ? ' Vorgang 2099-0001' : '');
app(MessageIntake::class)->handle(new IncomingMessage(
Medium::tryFrom((string) ($inputs['medium'] ?? 'whatsapp')) ?? Medium::WhatsApp, '+49170000000', $text, CarbonImmutable::now(), 'tester-'.md5($text),
$reference === 'none' ? null : $context->booking?->id, (bool) ($inputs['consent'] ?? true),
));
}),
];
}
}