Team API docs (#5897)
* let view_team permission be handled by global ACLs * code style and API docs * improve permission check
This commit is contained in:
@@ -21,7 +21,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
||||
class TeamVoterTest extends AbstractVoterTestCase
|
||||
{
|
||||
#[DataProvider('getTestData')]
|
||||
public function testVote(User $user, $subject, $attribute, $result): void
|
||||
public function testVote(User $user, mixed $subject, string $attribute, int $result): void
|
||||
{
|
||||
$token = new UsernamePasswordToken($user, 'bar', $user->getRoles());
|
||||
$sut = $this->getVoter(TeamVoter::class);
|
||||
@@ -29,7 +29,7 @@ class TeamVoterTest extends AbstractVoterTestCase
|
||||
self::assertEquals($result, $sut->vote($token, $subject, [$attribute]));
|
||||
}
|
||||
|
||||
public static function getTestData()
|
||||
public static function getTestData(): iterable
|
||||
{
|
||||
$user0 = self::getUser(0, null);
|
||||
$user1 = self::getUser(1, User::ROLE_USER);
|
||||
@@ -39,42 +39,42 @@ class TeamVoterTest extends AbstractVoterTestCase
|
||||
|
||||
$team = new Team('foo');
|
||||
|
||||
$result = VoterInterface::ACCESS_ABSTAIN;
|
||||
$abstain = VoterInterface::ACCESS_ABSTAIN;
|
||||
|
||||
$allTeamPerms = ['view_team', 'create_team', 'edit_team', 'delete_team'];
|
||||
|
||||
foreach ($allTeamPerms as $fullPerm) {
|
||||
yield [$user0, [], $fullPerm, $result];
|
||||
yield [$user0, new \stdClass(), $fullPerm, $result];
|
||||
yield [$user0, $team, $fullPerm, $result];
|
||||
yield [$user1, $team, $fullPerm, $result];
|
||||
yield [$user2, $team, $fullPerm, $result];
|
||||
yield [$user3, $team, $fullPerm, $result];
|
||||
yield [$user4, $team, $fullPerm, $result];
|
||||
yield [$user0, [], $fullPerm, $abstain];
|
||||
yield [$user0, new \stdClass(), $fullPerm, $abstain];
|
||||
yield [$user0, $team, $fullPerm, $abstain];
|
||||
yield [$user1, $team, $fullPerm, $abstain];
|
||||
yield [$user2, $team, $fullPerm, $abstain];
|
||||
yield [$user3, $team, $fullPerm, $abstain];
|
||||
yield [$user4, $team, $fullPerm, $abstain];
|
||||
}
|
||||
|
||||
$result = VoterInterface::ACCESS_DENIED;
|
||||
$denied = VoterInterface::ACCESS_DENIED;
|
||||
|
||||
yield [$user0, $team, 'view', $result];
|
||||
yield [$user0, $team, 'edit', $result];
|
||||
yield [$user0, $team, 'delete', $result];
|
||||
yield [$user0, $team, 'view', $abstain];
|
||||
yield [$user0, $team, 'edit', $denied];
|
||||
yield [$user0, $team, 'delete', $denied];
|
||||
|
||||
yield [$user1, $team, 'view', $result];
|
||||
yield [$user1, $team, 'edit', $result];
|
||||
yield [$user1, $team, 'delete', $result];
|
||||
yield [$user1, $team, 'view', $abstain];
|
||||
yield [$user1, $team, 'edit', $denied];
|
||||
yield [$user1, $team, 'delete', $denied];
|
||||
|
||||
yield [$user2, $team, 'view', $result];
|
||||
yield [$user2, $team, 'edit', $result];
|
||||
yield [$user2, $team, 'delete', $result];
|
||||
yield [$user2, $team, 'view', $abstain];
|
||||
yield [$user2, $team, 'edit', $denied];
|
||||
yield [$user2, $team, 'delete', $denied];
|
||||
|
||||
$result = VoterInterface::ACCESS_GRANTED;
|
||||
$granted = VoterInterface::ACCESS_GRANTED;
|
||||
|
||||
yield [$user3, $team, 'view', $result];
|
||||
yield [$user3, $team, 'edit', $result];
|
||||
yield [$user3, $team, 'delete', $result];
|
||||
yield [$user3, $team, 'view', $abstain];
|
||||
yield [$user3, $team, 'edit', $granted];
|
||||
yield [$user3, $team, 'delete', $granted];
|
||||
|
||||
yield [$user4, $team, 'view', $result];
|
||||
yield [$user4, $team, 'edit', $result];
|
||||
yield [$user4, $team, 'delete', $result];
|
||||
yield [$user4, $team, 'view', $abstain];
|
||||
yield [$user4, $team, 'edit', $granted];
|
||||
yield [$user4, $team, 'delete', $granted];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2381,26 +2381,6 @@ parameters:
|
||||
count: 1
|
||||
path: Voter/RolePermissionVoterTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Voter\\\\TeamVoterTest\\:\\:getTestData\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: Voter/TeamVoterTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Voter\\\\TeamVoterTest\\:\\:testVote\\(\\) has parameter \\$attribute with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Voter/TeamVoterTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Voter\\\\TeamVoterTest\\:\\:testVote\\(\\) has parameter \\$result with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Voter/TeamVoterTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Voter\\\\TeamVoterTest\\:\\:testVote\\(\\) has parameter \\$subject with no type specified\\.$#"
|
||||
count: 1
|
||||
path: Voter/TeamVoterTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\Voter\\\\TimesheetVoterTest\\:\\:assertVote\\(\\) has parameter \\$attribute with no type specified\\.$#"
|
||||
count: 1
|
||||
|
||||
Reference in New Issue
Block a user