test create text controller returns 400 when name missing
This commit is contained in:
parent
8a90c5bab4
commit
82dab3b90f
1 changed files with 20 additions and 0 deletions
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue