diff --git a/lib/Db/Board.php b/lib/Db/Board.php index 5026380d7..9125c2ca7 100644 --- a/lib/Db/Board.php +++ b/lib/Db/Board.php @@ -63,6 +63,10 @@ class Board extends RelationalEntity { if ($this->shared === -1) { unset($json['shared']); } + // FIXME: Ideally the API responses should follow the internal data structure and return null if the labels/acls have not been fetched from the db + // however this would be a breaking change for consumers of the API + $json['acl'] = $this->acl ?? []; + $json['labels'] = $this->labels ?? []; return $json; } diff --git a/tests/unit/Db/BoardTest.php b/tests/unit/Db/BoardTest.php index aa742ea8b..0c1814705 100644 --- a/tests/unit/Db/BoardTest.php +++ b/tests/unit/Db/BoardTest.php @@ -23,12 +23,35 @@ class BoardTest extends TestCase { 'title' => "My Board", 'owner' => "admin", 'color' => "000000", - 'labels' => null, + 'labels' => [], 'permissions' => [], 'stacks' => [], 'deletedAt' => 0, 'lastModified' => 0, - 'acl' => null, + 'acl' => [], + 'archived' => false, + 'users' => ['user1', 'user2'], + 'settings' => [], + 'ETag' => $board->getETag(), + ], $board->jsonSerialize()); + } + + public function testUnfetchedValues() { + $board = $this->createBoard(); + $board->setUsers(['user1', 'user2']); + self::assertNull($board->getAcl()); + self::assertNull($board->getLabels()); + $this->assertEquals([ + 'id' => 1, + 'title' => "My Board", + 'owner' => "admin", + 'color' => "000000", + 'labels' => [], + 'permissions' => [], + 'stacks' => [], + 'deletedAt' => 0, + 'lastModified' => 0, + 'acl' => [], 'archived' => false, 'users' => ['user1', 'user2'], 'settings' => [], @@ -49,7 +72,7 @@ class BoardTest extends TestCase { 'stacks' => [], 'deletedAt' => 0, 'lastModified' => 0, - 'acl' => null, + 'acl' => [], 'archived' => false, 'users' => [], 'settings' => [], @@ -72,12 +95,12 @@ class BoardTest extends TestCase { 'title' => "My Board", 'owner' => "admin", 'color' => "000000", - 'labels' => null, + 'labels' => [], 'permissions' => [], 'stacks' => [], 'deletedAt' => 0, 'lastModified' => 0, - 'acl' => null, + 'acl' => [], 'archived' => false, 'shared' => 1, 'users' => [],