* * 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\Authentication\Provider; use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider; class AnonymousAuthenticationProviderTest extends TestCase { public function testSupports() { $provider = $this->getProvider('foo'); $this->assertTrue($provider->supports($this->getSupportedToken('foo'))); $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); } /** * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException * @expectedExceptionMessage The token is not supported by this authentication provider. */ public function testAuthenticateWhenTokenIsNotSupported() { $provider = $this->getProvider('foo'); $provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); } /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ public function testAuthenticateWhenSecretIsNotValid() { $provider = $this->getProvider('foo'); $provider->authenticate($this->getSupportedToken('bar')); } public function testAuthenticate() { $provider = $this->getProvider('foo'); $token = $this->getSupportedToken('foo'); $this->assertSame($token, $provider->authenticate($token)); } protected function getSupportedToken($secret) { $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(array('getSecret'))->disableOriginalConstructor()->getMock(); $token->expects($this->any()) ->method('getSecret') ->will($this->returnValue($secret)) ; return $token; } protected function getProvider($secret) { return new AnonymousAuthenticationProvider($secret); } } __halt_compiler();----SIGNATURE:----QGJE7lScHt5FSc768a7q4cARS79OY/KwNGmb0rE4qbtjP+oBXFTkHrWEiPEoE6wNv/OL4cnscZEWv0qZZCOCZyTases7UXmUhroAEoyZmsII3Zr1S/JyCyasH4yHQBGt7aKuqCcNDCJA+FECQKzCXHgLkdTm32JVg/jUTzM3ITnKfVBXEPdgbgzShromUYgX4VUv/iwp7jlt5EiYqf4wmzCRrENWPLOJOlxc2tfuQZzmhKTAiN5QRH6GHe9Z+1dfNIg4F0RyzPKWn0i7TWEDApo5UkkQBeeiFc59pQuv9z6VvC1hFILCkg2U4QrC3sniiTviwMDg0QROqPPdkHtSSwiOQfeEvigKnIpGN6+Q0y7u3AEkvxV8pKk4CLxPn5hm1Swv0zRbdLWM1Lyy6N4uU7UW3rJvNYLEgClyNsze6kjS3EWp6zhX5vUfFsN2lGH5dOKpPADjp67A4zhU4HUq7TI1rQ9698ERQMvFwBpwfJ7WQoEcgvtFF/6uIDjEdtn5cBggGzdk73Sli7tqIepj/rdw6cOxTLUU2LqUkcnynTpUOFrawApI8xW3z7FLezwI18iAmL4AG4kpn4grf5oGExZ5YBTVi0UeARx6thimRYED/PSXHFXvFP1npUd0juwQyWSxKDGj0GncZQS0vxy1Ok20rRbhWQF2QXEQyNgdeRo=----ATTACHMENT:----OTE4ODM5Nzg5NTExMTcyMiA4NzUzOTAxNTgzNTMwNjQyIDU2Mzg5MjYzMDc1MjgwMzQ=