AnonymousTokenTest.php 1.2 KB

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