just testing the environment
Some checks failed
Tests / test (push) Has been cancelled

This commit is contained in:
tom.hempel
2026-05-20 07:10:08 +02:00
parent 2a11dfd0d1
commit 06fc134299
56 changed files with 1890 additions and 361 deletions

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
use QdbHttpResponse;
final class ResponseTest extends TestCase
{
protected function setUp(): void
{
require_once dirname(__DIR__, 2) . '/lib/response.php';
}
public function testJsonSuccessEnvelope(): void
{
try {
json_success(['token' => 'abc'], 201);
$this->fail('Expected QdbHttpResponse');
} catch (QdbHttpResponse $e) {
$this->assertSame(201, $e->status);
$this->assertTrue($e->body['ok']);
$this->assertSame(['token' => 'abc'], $e->body['data']);
}
}
public function testJsonErrorEnvelope(): void
{
try {
json_error('INVALID_CREDENTIALS', 'Bad login', 401);
$this->fail('Expected QdbHttpResponse');
} catch (QdbHttpResponse $e) {
$this->assertSame(401, $e->status);
$this->assertFalse($e->body['ok']);
$this->assertSame('INVALID_CREDENTIALS', $e->body['error']['code']);
$this->assertSame('Bad login', $e->body['error']['message']);
}
}
}