Development

Changeset 5634

You must first sign up to be able to contribute.

Changeset 5634

Show
Ignore:
Timestamp:
10/23/07 09:07:14 (11 months ago)
Author:
fabien
Message:

fixed sfValidatorBoolean

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/validator/sfValidatorBoolean.class.php

    r5581 r5634  
    3333    $this->setOption('true_values', array('true', 't', 'yes', 'y', 'on', '1')); 
    3434    $this->setOption('false_values', array('false', 'f', 'no', 'n', 'off', '0')); 
     35 
     36    $this->setOption('required', false); 
    3537  } 
    3638 
  • trunk/test/unit/validator/sfValidatorBooleanTest.php

    r5581 r5634  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(16, new lime_output_color()); 
     13$t = new lime_test(17, new lime_output_color()); 
    1414 
    1515$v = new sfValidatorBoolean(); 
     
    2121// ->clean() 
    2222$t->diag('->clean()'); 
    23  
    24 // empty 
    25 $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'); 
    3023 
    3124// true values 
     
    4336} 
    4437 
     38// required is false by default 
     39$t->is($v->clean(null), false, '->clean() returns false if the value is null'); 
     40 
    4541try 
    4642{ 
     
    5248  $t->pass('->clean() throws an error if the input value is not a true or a false value'); 
    5349} 
     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');