PreAuthenticatedTokenTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\PreAuthenticatedToken;
  12. use Symfony\Component\Security\Role\Role;
  13. class PreAuthenticatedTokenTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testConstructor()
  16. {
  17. $token = new PreAuthenticatedToken('foo', 'bar');
  18. $this->assertFalse($token->isAuthenticated());
  19. $token = new PreAuthenticatedToken('foo', 'bar', array('ROLE_FOO'));
  20. $this->assertTrue($token->isAuthenticated());
  21. $this->assertEquals(array(new Role('ROLE_FOO')), $token->getRoles());
  22. }
  23. public function testGetCredentials()
  24. {
  25. $token = new PreAuthenticatedToken('foo', 'bar');
  26. $this->assertEquals('bar', $token->getCredentials());
  27. }
  28. public function testGetUser()
  29. {
  30. $token = new PreAuthenticatedToken('foo', 'bar');
  31. $this->assertEquals('foo', $token->getUser());
  32. }
  33. public function testEraseCredentials()
  34. {
  35. $token = new PreAuthenticatedToken('foo', 'bar');
  36. $token->eraseCredentials();
  37. $this->assertEquals('', $token->getCredentials());
  38. }
  39. }