fix required fields in API (#1718)

This commit is contained in:
Kevin Papst
2020-05-19 11:24:30 +02:00
committed by GitHub
parent e61ffe4db4
commit 3c511df7f7
7 changed files with 58 additions and 2 deletions

View File

@@ -202,6 +202,23 @@ class ProjectControllerTest extends APIControllerBaseTest
self::assertEquals('2020-02-08T21:11:42+0000', $result['end']);
}
public function testPostActionWithLeastFields()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$data = [
'name' => 'foo',
'customer' => 1
];
$this->request($client, '/api/projects', 'POST', [], json_encode($data));
$this->assertTrue($client->getResponse()->isSuccessful());
$result = json_decode($client->getResponse()->getContent(), true);
$this->assertIsArray($result);
$this->assertStructure($result);
$this->assertNotEmpty($result['id']);
self::assertEquals('foo', $result['name']);
}
public function testPostActionWithInvalidUser()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);