* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\Tests\Authorization\Voter; use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver; use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; class AuthenticatedVoterTest extends TestCase { /** * @dataProvider getVoteTests */ public function testVote($authenticated, $attributes, $expected) { $voter = new AuthenticatedVoter($this->getResolver()); $this->assertSame($expected, $voter->vote($this->getToken($authenticated), null, $attributes)); } public function getVoteTests() { return array( array('fully', array(), VoterInterface::ACCESS_ABSTAIN), array('fully', array('FOO'), VoterInterface::ACCESS_ABSTAIN), array('remembered', array(), VoterInterface::ACCESS_ABSTAIN), array('remembered', array('FOO'), VoterInterface::ACCESS_ABSTAIN), array('anonymously', array(), VoterInterface::ACCESS_ABSTAIN), array('anonymously', array('FOO'), VoterInterface::ACCESS_ABSTAIN), array('fully', array('IS_AUTHENTICATED_ANONYMOUSLY'), VoterInterface::ACCESS_GRANTED), array('remembered', array('IS_AUTHENTICATED_ANONYMOUSLY'), VoterInterface::ACCESS_GRANTED), array('anonymously', array('IS_AUTHENTICATED_ANONYMOUSLY'), VoterInterface::ACCESS_GRANTED), array('fully', array('IS_AUTHENTICATED_REMEMBERED'), VoterInterface::ACCESS_GRANTED), array('remembered', array('IS_AUTHENTICATED_REMEMBERED'), VoterInterface::ACCESS_GRANTED), array('anonymously', array('IS_AUTHENTICATED_REMEMBERED'), VoterInterface::ACCESS_DENIED), array('fully', array('IS_AUTHENTICATED_FULLY'), VoterInterface::ACCESS_GRANTED), array('remembered', array('IS_AUTHENTICATED_FULLY'), VoterInterface::ACCESS_DENIED), array('anonymously', array('IS_AUTHENTICATED_FULLY'), VoterInterface::ACCESS_DENIED), ); } protected function getResolver() { return new AuthenticationTrustResolver( 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\AnonymousToken', 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\RememberMeToken' ); } protected function getToken($authenticated) { if ('fully' === $authenticated) { return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } elseif ('remembered' === $authenticated) { return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('setPersistent'))->disableOriginalConstructor()->getMock(); } else { return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(array('', ''))->getMock(); } } } __halt_compiler();----SIGNATURE:----VFiVbzkWoPtuBFPQUIaYwCi2fpbTKKvzcGzk8M7JpqMu7S8RZkI96uosriMmBXPf6FL1yGWbF4Dxltu3M1YI6q9QKoY+KfSi+1+kI0ak7NN0xIX5zBQRhiSONTOj8NrqlvTHxyAc4Ar+ND2OQVHmhEofcanKqTXUkFtFNBObIU1sHGcOVzPZhpdr29le91xFQnSWQkbr/rHawTRBVWaxW620BKfGypIrftErZDKi6y+ko6kB67oz25DeYtQdaM/X2yoGYvL8Hu2PVJAceFq1An48X2Qo2TMIwSdkW2hgLb+K/MxALJCF9mdLAUQavLByt2zdwcPELRNGso3zJHc7OmN4ENLYmCiON1gPJBOq9o1EtUyE19VA7sUuDtA903TYjL1IvFOK2w7PRg6MEnyeJBe8/gYy8N3NjGl9AygasPe5ZlJ4xOeSLsWjtHwwQJJX+39NHRkKug/FgWdTlThWevY/5JbRUYIL896X0zpD/d/A98Ft4Nae2R+4Gv2b86+SiTFmX5xKn8nokRTElsxbMvpILA5bZE/+QfOusVFq/A8a1/aN7v+as//h5YFc5mT2pWOKcoIuOkm5vZAg2m/gpV0LkiK8rggOdzfxiuc0O/e/sO9AKy9auKM8VE9JrA7Su/DZRsEdxCUZEPNCdM8T00ry4ff3/masKVySllJheiY=----ATTACHMENT:----ODU0NjI4MjQwMjc1MzQ0MiA4MjQ0ODAzODQ1OTg2NTc5IDEzMTU4MzI2MzYxMjU2MjI=