test create text controller returns 400 when name missing

This commit is contained in:
Yisroel Baum 2026-04-19 23:38:02 +03:00
parent 8a90c5bab4
commit 82dab3b90f
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -84,4 +84,24 @@ class TextControllerTest extends TestCase
$response->getBody() $response->getBody()
); );
} }
public function test_create_text_returns_400_when_name_missing(): void
{
$request = new ServerRequestFactory()
->createServerRequest('POST', 'http://localhost/texts')
->withParsedBody([]);
$response = $this->controller->createText(
$request,
new Response(),
new CreateText(
$this->textRepo,
new FakeNodeRepository(),
),
);
$this->assertEquals(400, $response->getStatusCode());
$body = json_decode($response->getBody(), true);
$this->assertArrayHasKey('error', $body);
}
} }