PlaintextPasswordEncoderTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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\Encoder;
  11. use Symfony\Component\Security\Encoder\PlaintextPasswordEncoder;
  12. class PlaintextPasswordEncoderTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testIsPasswordValid()
  15. {
  16. $encoder = new PlaintextPasswordEncoder();
  17. $this->assertSame(true, $encoder->isPasswordValid('foo', 'foo', ''));
  18. $this->assertSame(false, $encoder->isPasswordValid('bar', 'foo', ''));
  19. $this->assertSame(false, $encoder->isPasswordValid('FOO', 'foo', ''));
  20. $encoder = new PlaintextPasswordEncoder(true);
  21. $this->assertSame(true, $encoder->isPasswordValid('foo', 'foo', ''));
  22. $this->assertSame(false, $encoder->isPasswordValid('bar', 'foo', ''));
  23. $this->assertSame(true, $encoder->isPasswordValid('FOO', 'foo', ''));
  24. }
  25. public function testEncodePassword()
  26. {
  27. $encoder = new PlaintextPasswordEncoder();
  28. $this->assertSame('foo', $encoder->encodePassword('foo', ''));
  29. }
  30. }