diff --git a/lib/Db/AssignedUsersMapper.php b/lib/Db/AssignedUsersMapper.php index f7bc5c085..025570055 100644 --- a/lib/Db/AssignedUsersMapper.php +++ b/lib/Db/AssignedUsersMapper.php @@ -25,6 +25,7 @@ namespace OCA\Deck\Db; +use OCA\Deck\NotFoundException; use OCA\Deck\Service\CirclesService; use OCP\AppFramework\Db\Entity; use OCP\AppFramework\Db\QBMapper; @@ -97,7 +98,7 @@ public function findBoardId($cardId) { public function insert(Entity $entity): Entity { $origin = $this->getOrigin($entity); if ($origin === null) { - throw new \Exception('No origin found for assignment'); + throw new NotFoundException('No origin found for assignment'); } /** @var AssignedUsers $assignment */ $assignment = parent::insert($entity); diff --git a/tests/integration/database/AssignedUsersMapperTest.php b/tests/integration/database/AssignedUsersMapperTest.php index 37a709c65..06749117b 100644 --- a/tests/integration/database/AssignedUsersMapperTest.php +++ b/tests/integration/database/AssignedUsersMapperTest.php @@ -23,6 +23,7 @@ namespace OCA\Deck\Db; +use OCA\Deck\NotFoundException; use OCA\Deck\Service\AssignmentService; use OCA\Deck\Service\BoardService; use OCA\Deck\Service\StackService; @@ -165,8 +166,8 @@ public function testInsertInvalidUser() { $assignment->setCardId($this->cards[1]->getId()); $assignment->setParticipant('invalid-username'); $assignment->setType(AssignedUsers::TYPE_USER); - $actual = $this->assignedUsersMapper->insert($assignment); - $this->assertNull($actual); + $this->expectException(NotFoundException::class); + $this->assignedUsersMapper->insert($assignment); } /**