diff --git a/src/Security/PermissionSet/Repository/PermissionSet.php b/src/Security/PermissionSet/Repository/PermissionSet.php index 7ffe36cf2..097f66941 100644 --- a/src/Security/PermissionSet/Repository/PermissionSet.php +++ b/src/Security/PermissionSet/Repository/PermissionSet.php @@ -55,22 +55,6 @@ class PermissionSet extends BaseRepository $this->aclFormatter = $aclFormatter; } - /** - * replaces the PUBLIC id for the public permissionSet - * (no need to create the default permission set over and over again) - * - * @param $condition - */ - private function checkPublicSelect(&$condition) - { - if (empty($condition['allow_cid']) && - empty($condition['allow_gid']) && - empty($condition['deny_cid']) && - empty($condition['deny_gid'])) { - $condition['uid'] = self::PUBLIC; - } - } - /** * @param array $condition * @param array $params diff --git a/tests/src/Security/PermissionSet/Repository/PermissionSetTest.php b/tests/src/Security/PermissionSet/Repository/PermissionSetTest.php index ac0dd9afe..958512aa6 100644 --- a/tests/src/Security/PermissionSet/Repository/PermissionSetTest.php +++ b/tests/src/Security/PermissionSet/Repository/PermissionSetTest.php @@ -4,6 +4,7 @@ namespace Friendica\Test\src\Security\PermissionSet\Repository; use Friendica\Database\Database; use Friendica\Security\PermissionSet\Collection\PermissionSets; +use Friendica\Security\PermissionSet\Exception\PermissionSetNotFoundException; use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository; use Friendica\Security\PermissionSet\Entity\PermissionSet; use Friendica\Security\PermissionSet\Factory\PermissionSet as PermissionSetFactory; @@ -198,7 +199,6 @@ class PermissionSetTest extends FixtureTest /** @var Database $db */ $db = $this->dice->create(Database::class); - foreach ($inputPermissionSets as $inputPermissionSet) { $db->insert('permissionset', $inputPermissionSet); } @@ -209,4 +209,28 @@ class PermissionSetTest extends FixtureTest self::assertEqualPermissionSets($assertion['output'], $permissionSets); } } + + public function testSelectOneByIdInvalid() + { + self::expectException(PermissionSetNotFoundException::class); + self::expectExceptionMessage('PermissionSet with id -1 for user 42 doesn\'t exist.'); + + $this->repository->selectOneById(-1, 42); + } + + /** + * @dataProvider dataSet + */ + public function testSelectOneById(array $inputPermissionSets, array $assertions) + { + /** @var Database $db */ + $db = $this->dice->create(Database::class); + + foreach ($inputPermissionSets as $inputPermissionSet) { + $db->insert('permissionset', $inputPermissionSet); + $id = $db->lastInsertId(); + + self::assertInstanceOf(PermissionSet::class, $this->repository->selectOneById($id, $inputPermissionSet['uid'])); + } + } }