> */ public array $calls = []; public function __construct() { Http::fake(fn (Request $request): ?PromiseInterface => $this->responseFor($request)); } abstract protected function responseFor(Request $request): ?PromiseInterface; /** @return list> */ public function callsFor(string $method): array { return array_values(array_filter($this->calls, fn (array $call): bool => $call['method'] === $method)); } public function assertNothingHappened(): void { Assert::assertSame([], $this->calls, 'Expected no Wings requests to have been made.'); } /** @param array $arguments */ protected function record(string $method, array $arguments = []): void { $this->calls[] = ['method' => $method, ...$arguments]; } /** @param string|array $body */ protected function reply(string|array $body = ''): PromiseInterface { if ($this->throwable !== null) { throw $this->throwable; } if ($this->response !== null) { return Http::response((string) $this->response->getBody(), $this->response->getStatusCode(), $this->response->getHeaders()); } return Http::response($body); } /** @return array */ protected function query(Request $request): array { parse_str(parse_url($request->url(), PHP_URL_QUERY) ?: '', $query); return $query; } }