Files
fewo-stommer/app/Process/Tester/Scenarios/CompleteRequest.php
T

58 lines
2.3 KiB
PHP
Raw 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\AcceptOffer;
use App\Actions\SendOffer;
use App\Enums\BookingStatus;
use App\Enums\IntakeKind;
use App\Process\Tester\SandboxContext;
/**
* S01/S06/S11: a complete request – offer (automatic or by the landlord), acceptance, binding booking, arrival, after
* departure (review request, closing; a switched-off step is shown as skipped).
*/
final class CompleteRequest extends Scenario
{
public static function key(): string
{
return 'complete_request';
}
public static function label(): string
{
return 'Vollständige Anfrage bis zur Buchung';
}
public static function description(): string
{
return 'Ein Gast fragt mit allen Angaben an, erhält das Angebot und nimmt es an; danach Anreise und Abreise.';
}
public static function intakes(): array
{
return [IntakeKind::Inquiry];
}
public function events(array $inputs): array
{
return [
new ScenarioEvent('Gast fragt mit allen Angaben an', fn (SandboxContext $context) => $context->request(['street' => 'Teststraße 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'])),
new ScenarioEvent('Sie senden das Angebot (falls es nicht automatisch ging)', function (SandboxContext $context): void {
$booking = $context->booking->fresh();
if ($booking->status === BookingStatus::Reserved && $booking->offer_version === 0 && $booking->process()->preReservation()) {
app(SendOffer::class)->handle($booking);
}
}),
new ScenarioEvent('Gast nimmt das Angebot an', function (SandboxContext $context): void {
$booking = $context->booking->fresh();
if ($booking->status === BookingStatus::OfferSent) {
app(AcceptOffer::class)->handle($booking, $booking->offer_version);
}
}),
new ScenarioEvent('Zwei Tage vor der Anreise', fn (SandboxContext $context) => $context->travelTo($context->arrival()->subDays(2)->setTime(9, 0))),
new ScenarioEvent('Drei Tage nach der Abreise', fn (SandboxContext $context) => $context->travelTo($context->departure()->addDays(3)->setTime(9, 0))),
];
}
}