U-D/U-E/O5: Prozess-Tester im eigenen Prozess (standardmäßig gesperrt, 15 Negativtests, statischer Wächter), Szenarien und Bericht, Kanalereignisse (API-Eingang ohne Umbau von iCal/Mail), Abschluss nach finanzieller Klärung, Löschfrist 30 Tage
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c255783cec
commit
0689c0a591
68 files changed
+3350
-35
No files matched your search
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Tester;
|
||||
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use Illuminate\Http\Client\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
/**
|
||||
* The scripted network answers of a scenario (e.g. the landlord's AI access answering an extraction). Everything else
|
||||
* is refused by SandboxServiceProvider.
|
||||
*/
|
||||
final class SandboxNetwork
|
||||
{
|
||||
/** @var array<string, callable(Request): (PromiseInterface|array<string, mixed>|null)> host => answer */
|
||||
private static array $answers = [];
|
||||
|
||||
/**
|
||||
* @param callable(Request): (PromiseInterface|array<string, mixed>|null) $answer
|
||||
*/
|
||||
public static function script(string $host, callable $answer): void
|
||||
{
|
||||
self::$answers[$host] = $answer;
|
||||
}
|
||||
|
||||
public static function reset(): void
|
||||
{
|
||||
self::$answers = [];
|
||||
}
|
||||
|
||||
public static function answer(Request $request): ?PromiseInterface
|
||||
{
|
||||
$host = (string) parse_url($request->url(), PHP_URL_HOST);
|
||||
$answer = isset(self::$answers[$host]) ? (self::$answers[$host])($request) : null;
|
||||
|
||||
return match (true) {
|
||||
$answer === null => null,
|
||||
$answer instanceof PromiseInterface => $answer,
|
||||
default => Http::response($answer),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user