тело'); $this->assertSame('тело', $response->body()); $this->assertSame(200, $response->status()); $this->assertSame('text/html; charset=UTF-8', $response->headers()['Content-Type']); } public function testJsonResponseKeepsCyrillicReadable(): void { $response = Response::json(['error' => 'Сообщение пустое'], 422); $this->assertSame('{"error":"Сообщение пустое"}', $response->body()); $this->assertSame(422, $response->status()); $this->assertSame('application/json; charset=UTF-8', $response->headers()['Content-Type']); } public function testRedirectResponse(): void { $response = Response::redirect('/profile'); $this->assertSame(302, $response->status()); $this->assertSame('/profile', $response->headers()['Location']); $this->assertSame('', $response->body()); } public function testNotFoundResponse(): void { $this->assertSame(404, Response::notFound()->status()); } public function testHeadersAndStatusAreChainable(): void { $response = (new Response('тело')) ->withHeader('X-Test', 'значение') ->withStatus(201); $this->assertSame(201, $response->status()); $this->assertSame('значение', $response->headers()['X-Test']); } }