PasswordFieldTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\Form;
  11. require_once __DIR__.'/TestCase.php';
  12. use Symfony\Component\Form\PasswordField;
  13. class PasswordFieldTest extends TestCase
  14. {
  15. public function testGetDisplayedData_beforeSubmit()
  16. {
  17. $field = $this->factory->create('password', 'name');
  18. $field->setData('before');
  19. $this->assertSame('', $field->getRenderer()->getVar('value'));
  20. }
  21. public function testGetDisplayedData_afterSubmit()
  22. {
  23. $field = $this->factory->create('password', 'name');
  24. $field->bind('after');
  25. $this->assertSame('', $field->getRenderer()->getVar('value'));
  26. }
  27. public function testGetDisplayedDataWithAlwaysEmptyDisabled_beforeSubmit()
  28. {
  29. $field = $this->factory->create('password', 'name', array('always_empty' => false));
  30. $field->setData('before');
  31. $this->assertSame('', $field->getRenderer()->getVar('value'));
  32. }
  33. public function testGetDisplayedDataWithAlwaysEmptyDisabled_afterSubmit()
  34. {
  35. $field = $this->factory->create('password', 'name', array('always_empty' => false));
  36. $field->bind('after');
  37. $this->assertSame('after', $field->getRenderer()->getVar('value'));
  38. }
  39. }