AnonymousTokenTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Security\Authentication\Token;
  11. use Symfony\Component\Security\Authentication\Token\AnonymousToken;
  12. use Symfony\Component\Security\Role\Role;
  13. class AnonymousTokenTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testConstructor()
  16. {
  17. $token = new AnonymousToken('foo', 'bar');
  18. $this->assertTrue($token->isAuthenticated());
  19. $token = new AnonymousToken('foo', 'bar', array('ROLE_FOO'));
  20. $this->assertEquals(array(new Role('ROLE_FOO')), $token->getRoles());
  21. }
  22. public function testGetKey()
  23. {
  24. $token = new AnonymousToken('foo', 'bar');
  25. $this->assertEquals('foo', $token->getKey());
  26. }
  27. public function testGetCredentials()
  28. {
  29. $token = new AnonymousToken('foo', 'bar');
  30. $this->assertEquals('', $token->getCredentials());
  31. }
  32. public function testGetUser()
  33. {
  34. $token = new AnonymousToken('foo', 'bar');
  35. $this->assertEquals('bar', $token->getUser());
  36. }
  37. }