Changeset 5634
- Timestamp:
- 10/23/07 09:07:14 (11 months ago)
- Files:
-
- trunk/lib/validator/sfValidatorBoolean.class.php (modified) (1 diff)
- trunk/test/unit/validator/sfValidatorBooleanTest.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/validator/sfValidatorBoolean.class.php
r5581 r5634 33 33 $this->setOption('true_values', array('true', 't', 'yes', 'y', 'on', '1')); 34 34 $this->setOption('false_values', array('false', 'f', 'no', 'n', 'off', '0')); 35 36 $this->setOption('required', false); 35 37 } 36 38 trunk/test/unit/validator/sfValidatorBooleanTest.php
r5581 r5634 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 6, new lime_output_color());13 $t = new lime_test(17, new lime_output_color()); 14 14 15 15 $v = new sfValidatorBoolean(); … … 21 21 // ->clean() 22 22 $t->diag('->clean()'); 23 24 // empty25 $t->diag('empty');26 $v->setOption('required', false);27 $t->ok($v->clean(null) === null, '->clean() returns null if no value is given');28 $v->setOption('empty_value', true);29 $t->ok($v->clean(null) === true, '->clean() returns the value of the empty_value option if no value is given');30 23 31 24 // true values … … 43 36 } 44 37 38 // required is false by default 39 $t->is($v->clean(null), false, '->clean() returns false if the value is null'); 40 45 41 try 46 42 { … … 52 48 $t->pass('->clean() throws an error if the input value is not a true or a false value'); 53 49 } 50 51 // empty 52 $t->diag('empty'); 53 $v->setOption('required', false); 54 $t->ok($v->clean(null) === null, '->clean() returns null if no value is given'); 55 $v->setOption('empty_value', true); 56 $t->ok($v->clean(null) === true, '->clean() returns the value of the empty_value option if no value is given');