This commit is contained in:
Julien Fastré 2025-07-02 12:22:49 +02:00
parent e336d67fa7
commit 2c85de05b8
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 8 additions and 2 deletions

View File

@ -38,7 +38,10 @@ final class SavedExportVoter extends Voter
self::DUPLICATE, self::DUPLICATE,
]; ];
public function __construct(private readonly ExportManager $exportManager, private readonly AccessDecisionManagerInterface $accessDecisionManager) {} public function __construct(
private readonly ExportManager $exportManager,
private readonly AccessDecisionManagerInterface $accessDecisionManager,
) {}
protected function supports($attribute, $subject): bool protected function supports($attribute, $subject): bool
{ {

View File

@ -21,6 +21,7 @@ use PHPUnit\Framework\TestCase;
use Prophecy\Argument; use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
/** /**
@ -42,7 +43,9 @@ class SavedExportVoterTest extends TestCase
$exportManager->getExport('dummy_export')->willReturn($export->reveal()); $exportManager->getExport('dummy_export')->willReturn($export->reveal());
$exportManager->isGrantedForElement(Argument::any())->willReturn($isGranted); $exportManager->isGrantedForElement(Argument::any())->willReturn($isGranted);
$voter = new SavedExportVoter($exportManager->reveal()); $accessDecisionManager = $this->prophesize(AccessDecisionManagerInterface::class);
$voter = new SavedExportVoter($exportManager->reveal(), $accessDecisionManager->reveal());
$token = new UsernamePasswordToken($user, 'default', ['ROLE_USER']); $token = new UsernamePasswordToken($user, 'default', ['ROLE_USER']);
self::assertEquals($expectedResult, $voter->vote($token, $savedExport, [$attribute])); self::assertEquals($expectedResult, $voter->vote($token, $savedExport, [$attribute]));