PlaintextPasswordEncoderTest.php 1.2 KB

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