Add tests & remove unused method
This commit is contained in:
parent
71cdbcfc24
commit
130f97717d
|
@ -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
|
||||
|
|
|
@ -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']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user