fix: unit tests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2022-03-14 08:34:02 +01:00
parent f2456d796c
commit 975af7c056
4 changed files with 19 additions and 18 deletions

View File

@@ -320,9 +320,9 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
}
/**
* Reset Cache for a
* Reset Cache for a
* given board or a given user
*
*
* @param int|null $boardId
* @param int|null $userId
*/

View File

@@ -525,7 +525,7 @@ class BoardService {
$this->boardMapper->mapAcl($newAcl);
$this->changeHelper->boardChanged($boardId);
$board = $this->find($boardId);
$board = $this->boardMapper->find($boardId);
$this->clearBoardFromCache($board);
// TODO: use the dispatched event for this
@@ -728,7 +728,7 @@ class BoardService {
/**
* Clean a given board data
* from the Cache
*
*
* @param OCA\Deck\Db\Board $board
*/
private function clearBoardFromCache(Board $board) {

View File

@@ -241,6 +241,7 @@ class PermissionService {
if (array_key_exists((string) $boardId, $this->users) && !$refresh) {
return $this->users[(string) $boardId];
}
try {
$board = $this->boardMapper->find($boardId);
} catch (DoesNotExistException $e) {

View File

@@ -154,7 +154,7 @@ class BoardServiceTest extends TestCase {
->method('find')
->with(1)
->willReturn($b1);
$this->permissionService->expects($this->once())
$this->permissionService->expects($this->any())
->method('findUsers')
->willReturn([
'admin' => 'admin',
@@ -258,6 +258,11 @@ class BoardServiceTest extends TestCase {
->method('insert')
->with($acl)
->willReturn($acl);
$this->permissionService->expects($this->any())
->method('findUsers')
->willReturn([
'admin' => 'admin',
]);
$this->assertEquals($acl, $this->service->addAcl(
123, 'user', 'admin', true, true, true
));
@@ -306,7 +311,7 @@ class BoardServiceTest extends TestCase {
->method('checkPermission')
->withConsecutive(
[$this->boardMapper, 123, Acl::PERMISSION_SHARE, null],
[$this->boardMapper, 123, Acl::PERMISSION_MANAGE, null]
[$this->boardMapper, 123, Acl::PERMISSION_MANAGE, null]
);
} else {
$this->aclMapper->expects($this->once())
@@ -329,20 +334,10 @@ class BoardServiceTest extends TestCase {
$this->permissionService->expects($this->exactly(3))
->method('userCan')
->willReturnOnConsecutiveCalls(
$currentUserAcl[0],
$currentUserAcl[1],
$currentUserAcl[0],
$currentUserAcl[1],
$currentUserAcl[2]
);
/* $this->permissionService->expects($this->at(2))
->method('userCan')
->willReturn($currentUserAcl[0]);
$this->permissionService->expects($this->at(3))
->method('userCan')
->willReturn($currentUserAcl[1]);
$this->permissionService->expects($this->at(4))
->method('userCan')
->willReturn($currentUserAcl[2]); */
}
$user = $this->createMock(IUser::class);
@@ -357,6 +352,11 @@ class BoardServiceTest extends TestCase {
$acl->resolveRelation('participant', function ($participant) use (&$user) {
return null;
});
$this->permissionService->expects($this->any())
->method('findUsers')
->willReturn([
'admin' => 'admin',
]);
$this->notificationHelper->expects($this->once())
->method('sendBoardShared');
$expected = clone $acl;