* * 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\Token; use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Role\Role; class UsernamePasswordTokenTest extends TestCase { public function testConstructor() { $token = new UsernamePasswordToken('foo', 'bar', 'key'); $this->assertFalse($token->isAuthenticated()); $token = new UsernamePasswordToken('foo', 'bar', 'key', array('ROLE_FOO')); $this->assertEquals(array(new Role('ROLE_FOO')), $token->getRoles()); $this->assertTrue($token->isAuthenticated()); $this->assertEquals('key', $token->getProviderKey()); } /** * @expectedException \LogicException */ public function testSetAuthenticatedToTrue() { $token = new UsernamePasswordToken('foo', 'bar', 'key'); $token->setAuthenticated(true); } public function testSetAuthenticatedToFalse() { $token = new UsernamePasswordToken('foo', 'bar', 'key'); $token->setAuthenticated(false); $this->assertFalse($token->isAuthenticated()); } public function testEraseCredentials() { $token = new UsernamePasswordToken('foo', 'bar', 'key'); $token->eraseCredentials(); $this->assertEquals('', $token->getCredentials()); } public function testToString() { $token = new UsernamePasswordToken('foo', '', 'foo', array('A', 'B')); $this->assertEquals('UsernamePasswordToken(user="foo", authenticated=true, roles="A, B")', (string) $token); } } __halt_compiler();----SIGNATURE:----FxG6Yftc5ZrCEdT7TOdWSvbk8GrvTZ6gx/jE/50Gj27dwwVxnqs23/Uv+4Z77bAveZlCH/qqiyM9d5tYuq6bCYb4qQiQFyFBrqZ9EO0hcJ/LltLalnHp79dLjQvlem9ieP72gPkx+bBbm0WlrpVqc0SfIaflHHupM7ZhCZdOOFvcdfobLcGU0+PreFWsNIsUzZH++TrLrsUAoE3d2EOR3dkpjbazmyyjdTAKSFC5STfIAh4+3MEvJc04U+GoJGjELWFaa1KhPjVOFEcX11SZxSw1m7lGXWYWuRnikb9w+PQaIgyew2TAh0Tkpiqw17izWQYS9S+FAER/3N6l3teMqqSiHYWnbX+4D+w1DDtTJht/BZDHzSn7MIS9xFdv8Alr5dNrfFE282Lef+W6VLnn7lfIJXO2DrV4T8ef2K7HY2nl15cX8ZEeeqpHIk/ijgoCmfyHTDCyh4odHXB9p2C2BNm5Qv+rChzsq3ZvUhD6AJPh2RLy/00qFpQkpm2pP5pVVyKHYmyuyP+FAibt0kWV4ZvYWY64J7oLNCbf5WQ6TfPJh0Snu4DbLLAoMhhA4gakcf84CURSjrvTTGRmqBb4MNV0ci06wwc1+amk2+Y4UxHYhv3UBM8OtI/6qmHFJuP9aqGAkURKx9NIJc78Y2FoVoCUs0WGDkgnzdEnWhzdILU=----ATTACHMENT:----NTQ2NDMwNjYzNjEyMzA5NCA2MjYxMDk1NjQxOTA2NDI0IDE0MTUyMDg0OTQ5Mjg0NQ==