summaryrefslogtreecommitdiff
path: root/tests/PHPUnit/TestCases/HttpResponseTestCase.php
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-08-12 18:02:39 +0200
committerDaniel Weipert <git@mail.dweipert.de>2025-08-12 18:02:45 +0200
commit5ab89da146929734a39c7a55619b8bf8298ab832 (patch)
tree48746c1320b274f3c00f7c45aa7e512743e1ef75 /tests/PHPUnit/TestCases/HttpResponseTestCase.php
parent1fc29c6029cfa8c7dce5535ff9cfb2daaa6427e0 (diff)
implement phpunit integration tests
Diffstat (limited to 'tests/PHPUnit/TestCases/HttpResponseTestCase.php')
-rw-r--r--tests/PHPUnit/TestCases/HttpResponseTestCase.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/PHPUnit/TestCases/HttpResponseTestCase.php b/tests/PHPUnit/TestCases/HttpResponseTestCase.php
new file mode 100644
index 0000000..855e594
--- /dev/null
+++ b/tests/PHPUnit/TestCases/HttpResponseTestCase.php
@@ -0,0 +1,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;
+ }
+}