* * 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:----poL1iIuB7e41a7lCuaay80HFhTXe9g52Ziul8vKKnXObeE3H9YRyRyL3iKvrs0STwCPwPd+oXsT9Y8AGKC6kUuYnpyuieo5eYCOPzsw3EHfZxs+MkEpdlP1xqEnuZoKrMZd7L/0Ck+npN2tCIC40wxAsJ0A6QIp9U+OfmvCMla+FSmZGb1cLT+Jonk2DV58iLOJg+ulREDNDn5kBnmrYbyqIOFrtYawcBuPoKlj+pd2CEOFdY3yVAINYdjsJ/LnthhWM+17mIMVKRq78Rv+iE9b4wivA3TddXvoapFaR7xZifVrIyoj0fGSSUPlnFSyrKeQ82iq07HdPaMqyMNefxbR/pBaKxcbOnNljBzlSUacq5vvoiVz+Vi3LJB1e9BwUvum8WBpAD3UXrW8uSqsEEjKG5MM57znR6iPh7vyW4B+1txEn6jpDHErxEAP2kYRcjr7Xpk71bNJT1GDm+30ifX0EUvpjbJV1hLSBi4VSGu2kMZagXIxLUpJ2UVgs3Pr186qXqb9XZN026F34CW+0NcJM0UZY+nd71X0Mx/DD/+NmLLCf4a6wwP6d26rP5/ZDy/w1p+CzBDoPaIUwg+QrDYKSGIi2bLsE0cWhi9UU0RnIgXi09M4Pz839xyAqviN6stDwC1GpRNbttxacUgBpNhK5lIVPnAkoqWotEGfTVEI=----ATTACHMENT:----NDIzNjQzMzUzMTYxNTY0MiA5MTQ0NzA2MzA3MDg5MzQwIDgwNzQyMDY5MzM1MTUwMTU=