blob: 31dc1d7560bcefd92b82ccf108ee89bebc6bce8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<?php
namespace Tests\PHPUnit\TestCases;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase;
class HttpResponseTestCase extends TestCase
{
protected Client $client;
protected function setUp(): void
{
$this->client = new Client([
"base_uri" => "http://localhost:8080",
]);
}
/**
* @param array $options
*/
public function request(string $method, string $path, array $options = []): Response
{
return $this->client->request(
$method,
$path,
["http_errors" => false] + $options
);
}
public function hasJsonBody(Response $response): bool
{
json_decode((string)$response->getBody());
return json_last_error() === JSON_ERROR_NONE;
}
}
|