'01001000', 'logradouro' => 'Praça da Sé', 'complemento' => 'lado ímpar', 'unidade' => '', 'bairro' => 'Sé', 'localidade' => 'São Paulo', 'uf' => 'SP', 'estado' => 'São Paulo', 'regiao' => 'Sudeste', 'ibge' => '3550308', 'gia' => '1004', 'ddd' => '11', 'siafi' => '7107', ]; protected const CSV_HEADER = 'cep,logradouro,complemento,unidade,bairro,localidade,uf,' . 'estado,regiao,ibge,gia,ddd,siafi'; protected TestServer $server; protected Client $client; protected function setUp(): void { $this->server = new TestServer(); $this->client = new Client( baseUrl: $this->server->url, timeout: 5.0, backoffBase: 0.001, backoffMax: 0.01, ); } protected function tearDown(): void { $this->server->stop(); } /** * @param array $body * @param array $headers * * @return array */ protected static function json(array $body, int $status = 200, array $headers = []): array { return [ 'status' => $status, 'body' => json_encode($body, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE), 'headers' => $headers, 'content_type' => 'application/json; charset=utf-8', ]; } /** * @param array $headers * * @return array */ protected static function raw(int $status, string $body, array $headers = []): array { return ['status' => $status, 'body' => $body, 'headers' => $headers]; } /** * @param list $rows * * @return array */ protected static function csv(array $rows): array { return [ 'status' => 200, 'body' => self::CSV_HEADER . "\n" . implode("\n", $rows) . "\n", 'headers' => [], 'content_type' => 'text/csv; charset=utf-8', ]; } protected static function monotonic(): float { return hrtime(true) / 1_000_000_000; } }