*/ private array $postQueue = []; /** @var list */ private array $getQueue = []; /** @var list,headers:array}> */ public array $postCalls = []; /** @var list}> */ public array $getCalls = []; /** * @param array{status:int,body:string} $response */ public function queuePost(array $response): void { $this->postQueue[] = $response; } /** * @param array{status:int,body:string} $response */ public function queueGet(array $response): void { $this->getQueue[] = $response; } public function postForm(string $url, array $fields, array $headers = []): array { /** @var array $fields */ /** @var array $headers */ $this->postCalls[] = ['url' => $url, 'fields' => $fields, 'headers' => $headers]; if ($this->postQueue === []) { throw new \RuntimeException('No fake POST response queued'); } return array_shift($this->postQueue); } public function get(string $url, array $headers = []): array { /** @var array $headers */ $this->getCalls[] = ['url' => $url, 'headers' => $headers]; if ($this->getQueue === []) { throw new \RuntimeException('No fake GET response queued'); } return array_shift($this->getQueue); } }