RoleHierarchyVoterTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Security\Authorization\Voter;
  11. use Symfony\Component\Security\Authorization\Voter\RoleHierarchyVoter;
  12. use Symfony\Component\Security\Authorization\Voter\VoterInterface;
  13. use Symfony\Component\Security\Role\RoleHierarchy;
  14. require_once __DIR__.'/RoleVoterTest.php';
  15. class RoleHierarchyVoterTest extends RoleVoterTest
  16. {
  17. /**
  18. * @dataProvider getVoteTests
  19. */
  20. public function testVote($roles, $attributes, $expected)
  21. {
  22. $voter = new RoleHierarchyVoter(new RoleHierarchy(array('ROLE_FOO' => array('ROLE_FOOBAR'))));
  23. $this->assertSame($expected, $voter->vote($this->getToken($roles), null, $attributes));
  24. }
  25. public function getVoteTests()
  26. {
  27. return array_merge(parent::getVoteTests(), array(
  28. array(array('ROLE_FOO'), array('ROLE_FOOBAR'), VoterInterface::ACCESS_GRANTED),
  29. ));
  30. }
  31. }