summaryrefslogtreecommitdiff
path: root/tests/Integration/TestCases/HttpResponseTestCase.php
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-08-26 11:30:49 +0200
committerDaniel Weipert <git@mail.dweipert.de>2025-08-26 11:30:49 +0200
commitdb014ebf9f8f84a1a0d0972298e70bf29e57c37e (patch)
treefbb4ee22f913b048e3c58720ddd77be8c5805efb /tests/Integration/TestCases/HttpResponseTestCase.php
parent6dc0447320272aaae51a98eb6606597019f986d3 (diff)
create .cache directory and move tests to Integration directory
Diffstat (limited to 'tests/Integration/TestCases/HttpResponseTestCase.php')
-rw-r--r--tests/Integration/TestCases/HttpResponseTestCase.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/Integration/TestCases/HttpResponseTestCase.php b/tests/Integration/TestCases/HttpResponseTestCase.php
new file mode 100644
index 0000000..43b4859
--- /dev/null
+++ b/tests/Integration/TestCases/HttpResponseTestCase.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Tests\Integration\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;
+ }
+}