use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
use Symfony\Component\Security\Core\Authorization\Voter\RoleVoter;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
class RoleVoterTest extends TestCase
{ /**
* @dataProvider getVoteTests
*/
public function testVoteUsingTokenThatReturnsRoleNames($roles,
$attributes,
$expected) { $voter =
new RoleVoter();
$this->
assertSame($expected,
$voter->
vote($this->
getTokenWithRoleNames($roles), null,
$attributes));
} public static function getVoteTests() { return [ [[],
[], VoterInterface::ACCESS_ABSTAIN
],
[[],
['FOO'
], VoterInterface::ACCESS_ABSTAIN
],
[[],
['ROLE_FOO'
], VoterInterface::ACCESS_DENIED
],
[['ROLE_FOO'
],
['ROLE_FOO'
], VoterInterface::ACCESS_GRANTED
],
[[