PageRenderTime 61ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/sfFormExtraPlugin/test/validator/sfValidatorDefaultTest.php

https://bitbucket.org/Kudlaty/360kdw
PHP | 35 lines | 20 code | 7 blank | 8 comment | 0 complexity | 92b4a5838358108197afe3afe8aee679 MD5 | raw file
Possible License(s): LGPL-2.1
  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. require_once dirname(__FILE__).'/../bootstrap.php';
  10. require_once dirname(__FILE__).'/../../lib/validator/sfValidatorDefault.class.php';
  11. $t = new lime_test(4);
  12. // ->clean()
  13. $t->diag('->clean()');
  14. $validator = new sfValidatorDefault(array(
  15. 'validator' => new sfValidatorString(),
  16. 'default' => '==DEFAULT==',
  17. ));
  18. $t->is($validator->clean('foo'), 'foo', '->clean() returns cleaned values');
  19. $t->is($validator->clean(null), '==DEFAULT==', '->clean() returns the default on validation failure');
  20. $validator = new sfValidatorDefault(array(
  21. 'validator' => new sfValidatorString(array('empty_value' => '==EMPTY==')),
  22. ));
  23. $t->is($validator->clean(null), '==EMPTY==', '->clean() returns the validator empty value if no default value is set');
  24. $validator = new sfValidatorDefault(array(
  25. 'validator' => new sfValidatorString(array('empty_value' => '==EMPTY==')),
  26. 'default' => '==DEFAULT==',
  27. ));
  28. $t->is($validator->clean(null), '==DEFAULT==', '->clean() returns the default if both default and the embedded empty value are set');