diff --git a/lib/Db/AssignmentMapper.php b/lib/Db/AssignmentMapper.php index 85a9cf197..1abe144ec 100644 --- a/lib/Db/AssignmentMapper.php +++ b/lib/Db/AssignmentMapper.php @@ -114,7 +114,7 @@ class AssignmentMapper extends QBMapper implements IPermissionMapper { } public function isUserAssigned($cardId, $userId): bool { - $assignments = $this->find($cardId); + $assignments = $this->findAll($cardId); foreach ($assignments as $assignment) { $origin = $this->getOrigin($assignment); if ($origin instanceof User && $assignment->getParticipant() === $userId) { diff --git a/lib/Notification/NotificationHelper.php b/lib/Notification/NotificationHelper.php index 299e1332d..723923925 100644 --- a/lib/Notification/NotificationHelper.php +++ b/lib/Notification/NotificationHelper.php @@ -26,7 +26,7 @@ namespace OCA\Deck\Notification; use DateTime; use OCA\Deck\AppInfo\Application; use OCA\Deck\Db\Acl; -use OCA\Deck\Db\AssignedUsersMapper; +use OCA\Deck\Db\AssignmentMapper; use OCA\Deck\Db\Board; use OCA\Deck\Db\BoardMapper; use OCA\Deck\Db\CardMapper; @@ -44,8 +44,8 @@ class NotificationHelper { protected $cardMapper; /** @var BoardMapper */ protected $boardMapper; - /** @var AssignedUsersMapper */ - protected $assignedUsersMapper; + /** @var AssignmentMapper */ + protected $assignmentMapper; /** @var PermissionService */ protected $permissionService; /** @var IConfig */ @@ -62,7 +62,7 @@ class NotificationHelper { public function __construct( CardMapper $cardMapper, BoardMapper $boardMapper, - AssignedUsersMapper $assignedUsersMapper, + AssignmentMapper $assignmentMapper, PermissionService $permissionService, IConfig $config, IManager $notificationManager, @@ -71,7 +71,7 @@ class NotificationHelper { ) { $this->cardMapper = $cardMapper; $this->boardMapper = $boardMapper; - $this->assignedUsersMapper = $assignedUsersMapper; + $this->assignmentMapper = $assignmentMapper; $this->permissionService = $permissionService; $this->config = $config; $this->notificationManager = $notificationManager; @@ -107,7 +107,7 @@ class NotificationHelper { if ($user->getUID() === $board->getOwner() && count($board->getAcl()) === 0) { // Notify if all or assigned is configured for unshared boards $shouldNotify = true; - } elseif ($notificationSetting === ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED && $this->assignedUsersMapper->isUserAssigned($card->getId(), $user->getUID())) { + } elseif ($notificationSetting === ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED && $this->assignmentMapper->isUserAssigned($card->getId(), $user->getUID())) { // Notify if the user is assigned and has the assigned setting selected $shouldNotify = true; } diff --git a/tests/integration/database/AssignmentMapperTest.php b/tests/integration/database/AssignmentMapperTest.php index 56b53e27f..6999e1093 100644 --- a/tests/integration/database/AssignmentMapperTest.php +++ b/tests/integration/database/AssignmentMapperTest.php @@ -165,7 +165,7 @@ class AssignmentMapperTest extends \Test\TestCase { $assignment = new Assignment(); $assignment->setCardId($this->cards[1]->getId()); $assignment->setParticipant('invalid-username'); - $assignment->setType(AssignedUsers::TYPE_USER); + $assignment->setType(Assignment::TYPE_USER); $this->expectException(NotFoundException::class); $this->assignedUsersMapper->insert($assignment); } @@ -190,10 +190,10 @@ class AssignmentMapperTest extends \Test\TestCase { } public function testIsUserAssigned() { - $assignment = new AssignedUsers(); + $assignment = new Assignment(); $assignment->setCardId($this->cards[1]->getId()); $assignment->setParticipant(self::TEST_USER4); - $assignment->setType(AssignedUsers::TYPE_USER); + $assignment->setType(Assignment::TYPE_USER); $this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER4)); $assignment = $this->assignedUsersMapper->insert($assignment); @@ -205,10 +205,10 @@ class AssignmentMapperTest extends \Test\TestCase { } public function testIsUserAssignedGroup() { - $assignment = new AssignedUsers(); + $assignment = new Assignment(); $assignment->setCardId($this->cards[1]->getId()); $assignment->setParticipant('group'); - $assignment->setType(AssignedUsers::TYPE_GROUP); + $assignment->setType(Assignment::TYPE_GROUP); $this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER1)); $this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER2)); $this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER3)); diff --git a/tests/unit/Service/AssignmentServiceTest.php b/tests/unit/Service/AssignmentServiceTest.php index e12f3398e..56414c54a 100644 --- a/tests/unit/Service/AssignmentServiceTest.php +++ b/tests/unit/Service/AssignmentServiceTest.php @@ -115,7 +115,7 @@ class AssignmentServiceTest extends TestCase { public function testAssignUser() { $assignments = []; $this->assignedUsersMapper->expects($this->once()) - ->method('find') + ->method('findAll') ->with(123) ->willReturn($assignments); $assignment = new Assignment(); @@ -145,7 +145,7 @@ class AssignmentServiceTest extends TestCase { $this->expectExceptionMessage('The user is not part of the board'); $assignments = []; $this->assignedUsersMapper->expects($this->once()) - ->method('find') + ->method('findAll') ->with(123) ->willReturn($assignments); $assignment = new Assignment(); @@ -176,7 +176,7 @@ class AssignmentServiceTest extends TestCase { $assignment ]; $this->assignedUsersMapper->expects($this->once()) - ->method('find') + ->method('findAll') ->with(123) ->willReturn($assignments); $actual = $this->assignmentService->assignUser(123, 'admin'); @@ -192,7 +192,7 @@ class AssignmentServiceTest extends TestCase { $assignment ]; $this->assignedUsersMapper->expects($this->once()) - ->method('find') + ->method('findAll') ->with(123) ->willReturn($assignments); $this->assignedUsersMapper->expects($this->once()) @@ -213,7 +213,7 @@ class AssignmentServiceTest extends TestCase { $assignment ]; $this->assignedUsersMapper->expects($this->once()) - ->method('find') + ->method('findAll') ->with(123) ->willReturn($assignments); $this->expectException(NotFoundException::class);