diff --git a/lib/DAV/DeckCalendarBackend.php b/lib/DAV/DeckCalendarBackend.php index a1849abe9..cbb602c94 100644 --- a/lib/DAV/DeckCalendarBackend.php +++ b/lib/DAV/DeckCalendarBackend.php @@ -59,7 +59,7 @@ class DeckCalendarBackend { } public function getBoards(): array { - return $this->boardService->findAll(-1, null, false); + return $this->boardService->findAll(-1, false, false); } public function getBoard(int $id): Board { diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index ce3326474..1ef0a42cf 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -160,7 +160,7 @@ class BoardService { } $complete = $this->getUserBoards($since, $includeArchived); - return $this->enrichBoards($complete, $fullDetails !== null); + return $this->enrichBoards($complete, $fullDetails); } /** @@ -675,7 +675,6 @@ class BoardService { } else { $this->boardsCachePartial[$board->getId()] = $board; } - } return $boards; @@ -703,7 +702,7 @@ class BoardService { private function enrichWithUsers($board, $since = -1) { $boardUsers = $this->permissionService->findUsers($board->getId()); - if (\count($boardUsers) === 0) { + if ($boardUsers === null || \count($boardUsers) === 0) { return; } $board->setUsers(array_values($boardUsers)); diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index ad134e225..b44a094d9 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -175,7 +175,7 @@ class CardService { public function find(int $cardId) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ); $card = $this->cardMapper->find($cardId); - $this->enrichCards([$card]); + [$card] = $this->enrichCards([$card]); // Attachments are only enriched on individual card fetching $attachments = $this->attachmentService->findAll($cardId, true); diff --git a/tests/unit/Service/CardServiceTest.php b/tests/unit/Service/CardServiceTest.php index f2f5c71f3..1952747b3 100644 --- a/tests/unit/Service/CardServiceTest.php +++ b/tests/unit/Service/CardServiceTest.php @@ -156,7 +156,8 @@ class CardServiceTest extends TestCase { ->method('getNumberOfCommentsForObject') ->willReturn(0); $boardMock = $this->createMock(Board::class); - $stackMock = $this->createMock(Stack::class); + $stackMock = new Stack(); + $stackMock->setBoardId(1234); $this->stackMapper->expects($this->any()) ->method('find') ->willReturn($stackMock); diff --git a/tests/unit/controller/BoardControllerTest.php b/tests/unit/controller/BoardControllerTest.php index fdb0ae203..357219907 100644 --- a/tests/unit/controller/BoardControllerTest.php +++ b/tests/unit/controller/BoardControllerTest.php @@ -24,6 +24,7 @@ namespace OCA\Deck\Controller; use OCA\Deck\Db\Acl; +use OCA\Deck\Db\Board; use OCP\IUser; class BoardControllerTest extends \Test\TestCase { @@ -88,11 +89,12 @@ class BoardControllerTest extends \Test\TestCase { } public function testRead() { + $board = new Board(); $this->boardService->expects($this->once()) ->method('find') ->with(123) - ->willReturn(1); - $this->assertEquals(1, $this->controller->read(123)); + ->willReturn($board); + $this->assertEquals($board, $this->controller->read(123)); } public function testCreate() {