21 lines
787 B
PHP
21 lines
787 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
namespace App\Tests;
|
|
use App\Http\{Request, Response};
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class HttpTest extends TestCase
|
|
{
|
|
public function testRequestJsonAndHeaderCaseInsensitive(): void {
|
|
$r = new Request('POST', '/api/events', ['X-Nonce' => 'n1'], '{"a":1}', [], []);
|
|
$this->assertSame('POST', $r->method());
|
|
$this->assertSame('n1', $r->header('x-nonce'));
|
|
$this->assertSame(['a' => 1], $r->json());
|
|
}
|
|
public function testResponseJson(): void {
|
|
$res = Response::json(['ok' => true], 201);
|
|
$this->assertSame(201, $res->status());
|
|
$this->assertStringContainsString('application/json', $res->headers()['Content-Type']);
|
|
$this->assertSame('{"ok":true}', $res->body());
|
|
}
|
|
}
|