From cae999ec80c7c96e1bb6a497befb678a95aa7c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 2 Mar 2018 18:08:53 +0100 Subject: [PATCH] Fix tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- tests/unit/Service/BoardServiceTest.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/unit/Service/BoardServiceTest.php b/tests/unit/Service/BoardServiceTest.php index ba0221742..c7b89e79f 100644 --- a/tests/unit/Service/BoardServiceTest.php +++ b/tests/unit/Service/BoardServiceTest.php @@ -26,6 +26,8 @@ use OC\L10N\L10N; use OCA\Deck\Db\Acl; use OCA\Deck\Db\AclMapper; +use OCA\Deck\Db\AssignedUsers; +use OCA\Deck\Db\AssignedUsersMapper; use OCA\Deck\Db\Board; use OCA\Deck\Db\BoardMapper; use OCA\Deck\Db\LabelMapper; @@ -49,6 +51,8 @@ class BoardServiceTest extends TestCase { private $permissionService; /** @var NotificationHelper */ private $notificationHelper; + /** @var AssignedUsersMapper */ + private $assignedUsersMapper; private $userId = 'admin'; @@ -60,6 +64,7 @@ public function setUp() { $this->labelMapper = $this->createMock(LabelMapper::class); $this->permissionService = $this->createMock(PermissionService::class); $this->notificationHelper = $this->createMock(NotificationHelper::class); + $this->assignedUsersMapper = $this->createMock(AssignedUsersMapper::class); $this->service = new BoardService( $this->boardMapper, @@ -67,7 +72,8 @@ public function setUp() { $this->labelMapper, $this->aclMapper, $this->permissionService, - $this->notificationHelper + $this->notificationHelper, + $this->assignedUsersMapper ); $user = $this->createMock(IUser::class); @@ -224,7 +230,7 @@ public function testUpdateAcl() { public function testDeleteAcl() { $acl = new Acl(); $acl->setBoardId(123); - $acl->setType('user'); + $acl->setType(Acl::PERMISSION_TYPE_USER); $acl->setParticipant('admin'); $acl->setPermissionEdit(true); $acl->setPermissionShare(true); @@ -233,6 +239,15 @@ public function testDeleteAcl() { ->method('find') ->with(123) ->willReturn($acl); + $assignment = new AssignedUsers(); + $assignment->setParticipant('admin'); + $this->assignedUsersMapper->expects($this->once()) + ->method('findByUserId') + ->with('admin') + ->willReturn([$assignment]); + $this->assignedUsersMapper->expects($this->once()) + ->method('delete') + ->with($assignment); $this->aclMapper->expects($this->once()) ->method('delete') ->with($acl)