Support visibility for tags (#4086)
This commit is contained in:
@@ -313,6 +313,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
'id' => 'int',
|
||||
'name' => 'string',
|
||||
'color' => '@string',
|
||||
'visible' => 'bool',
|
||||
];
|
||||
|
||||
// embedded meta data
|
||||
|
||||
@@ -33,17 +33,20 @@ class TagControllerTest extends APIControllerBaseTest
|
||||
return $this->importFixture($fixture);
|
||||
}
|
||||
|
||||
public function testIsSecure()
|
||||
public function testIsSecure(): void
|
||||
{
|
||||
$this->assertUrlIsSecured('/api/tags');
|
||||
}
|
||||
|
||||
public function testGetCollection()
|
||||
public function testGetCollection(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->importTagFixtures();
|
||||
$this->assertAccessIsGranted($client, '/api/tags');
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$content = $client->getResponse()->getContent();
|
||||
$this->assertNotFalse($content);
|
||||
$result = json_decode($content, true);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertNotEmpty($result);
|
||||
@@ -51,20 +54,23 @@ class TagControllerTest extends APIControllerBaseTest
|
||||
$this->assertEquals('Test', $result[9]);
|
||||
}
|
||||
|
||||
public function testEmptyCollection()
|
||||
public function testEmptyCollection(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->importTagFixtures();
|
||||
$query = ['name' => 'nothing'];
|
||||
$this->assertAccessIsGranted($client, '/api/tags', 'GET', $query);
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$content = $client->getResponse()->getContent();
|
||||
$this->assertNotFalse($content);
|
||||
$result = json_decode($content, true);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertEmpty($result);
|
||||
$this->assertEquals(0, \count($result));
|
||||
}
|
||||
|
||||
public function testPostAction()
|
||||
public function testPostAction(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$this->importTagFixtures();
|
||||
@@ -75,14 +81,17 @@ class TagControllerTest extends APIControllerBaseTest
|
||||
$this->request($client, '/api/tags', 'POST', [], json_encode($data));
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
$content = $client->getResponse()->getContent();
|
||||
$this->assertNotFalse($content);
|
||||
$result = json_decode($content, true);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
self::assertApiResponseTypeStructure('TagEntity', $result);
|
||||
$this->assertNotEmpty($result['id']);
|
||||
self::assertEquals('#00ff00', $result['color']);
|
||||
}
|
||||
|
||||
public function testPostActionWithValidationErrors()
|
||||
public function testPostActionWithValidationErrors(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$this->importTagFixtures();
|
||||
@@ -96,7 +105,7 @@ class TagControllerTest extends APIControllerBaseTest
|
||||
$this->assertApiCallValidationError($response, ['name', 'color']);
|
||||
}
|
||||
|
||||
public function testPostActionAsRegularUser()
|
||||
public function testPostActionAsRegularUser(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->importTagFixtures();
|
||||
@@ -106,20 +115,26 @@ class TagControllerTest extends APIControllerBaseTest
|
||||
$this->request($client, '/api/tags', 'POST', [], json_encode($data));
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
$content = $client->getResponse()->getContent();
|
||||
$this->assertNotFalse($content);
|
||||
$result = json_decode($content, true);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
self::assertApiResponseTypeStructure('TagEntity', $result);
|
||||
$this->assertNotEmpty($result['id']);
|
||||
self::assertEquals('foo', $result['name']);
|
||||
}
|
||||
|
||||
public function testPartOfEntries()
|
||||
public function testPartOfEntries(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->importTagFixtures();
|
||||
$query = ['name' => 'in'];
|
||||
$this->assertAccessIsGranted($client, '/api/tags', 'GET', $query);
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$content = $client->getResponse()->getContent();
|
||||
$this->assertNotFalse($content);
|
||||
$result = json_decode($content, true);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertNotEmpty($result);
|
||||
@@ -130,7 +145,7 @@ class TagControllerTest extends APIControllerBaseTest
|
||||
$this->assertEquals('Marketing', $result[2]);
|
||||
}
|
||||
|
||||
public function testDeleteAction()
|
||||
public function testDeleteAction(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$tags = $this->importTagFixtures();
|
||||
@@ -142,12 +157,15 @@ class TagControllerTest extends APIControllerBaseTest
|
||||
$this->assertEmpty($client->getResponse()->getContent());
|
||||
|
||||
$this->assertAccessIsGranted($client, '/api/tags');
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$content = $client->getResponse()->getContent();
|
||||
$this->assertNotFalse($content);
|
||||
$result = json_decode($content, true);
|
||||
|
||||
$this->assertEquals(9, \count($result));
|
||||
}
|
||||
|
||||
public function testDeleteActionWithUnknownTimesheet()
|
||||
public function testDeleteActionWithUnknownTimesheet(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$this->assertNotFoundForDelete($client, '/api/tags/' . PHP_INT_MAX);
|
||||
|
||||
Reference in New Issue
Block a user