* * 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:----IMLjQZwulEteT26GOPUUt+VIp8qY2ATMfU3DezBBrJZthDebeh3TT2eGbnXqsdE3EIAnzaPkp+tARAVQtDxV1o+xtHwtdzJ59DWZdtHkmGD31CWfw52IiR+42+je9P1IyEFoCBPd4mX0MFkVfheIoZObAfBgHHngOr2Jo7CzEgu9oycC2tWXTjDsGne1cxisRiIIMUSGejvcBWBIgsxNxe3+nHd7+bR7QkFAV5TWKbk6qYZLCzpU97TGWxzyJm8xvuDYOr185y/URox2Jv0xq99TjdXA2buEUvgeKx6UVCyhBKLxijN4eV2CJU2Hvj27wCinTbAFiPyMA7bxjYY92RxGmzqxCkEQ/K8wlS3QwrNnQlnjOqk4Zd65qVThQmHc0DSiUavDJHh5j57SLALKamUZAmxE2CSc7GmW+ZxlvNDEB359Hz5SdtOPHYeyPdTBG+DmKSlwWn60/R2Ay+hRjVCite0b13vlz0LD8BDikgyIHxRQrk1p1EmFAFLcz3zTtenTPQa/UH3H5rNpWLjlQiFhS9jE/aQgoZ3u0RkRyY7w5mWbxM5HVRudeCKbu4oSkxqjSMCyIUxMHZX03nazplKo9vGCPXH2vQ0TbYNF9KCuFTrb3OfOpjNfOwhafBMj7vG00Jx6YlCeqM4BhKlUFUs0remUZr32PidrkJCt3M0=----ATTACHMENT:----MzQwNTU0NTI5MTg0NTE0MCA0MTgyNzE0MjY0MDYyMTI4IDM3Nzc1Nzg3MzcxMzAzNjg=