Development

Changeset 5757

You must first sign up to be able to contribute.

Changeset 5757

Show
Ignore:
Timestamp:
10/30/07 07:35:06 (1 year ago)
Author:
fabien
Message:

renamed expected option to choices for sfValidatorChoice

Files:

Legend:

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

    r5753 r5757  
    2424   * Available options: 
    2525   * 
    26    *  * expected: An array of expected values 
     26   *  * choices: An array of expected values 
    2727   * 
    2828   * @see sfValidator 
     
    3030  public function __construct($options = array(), $messages = array()) 
    3131  { 
    32     if (!isset($options['expected'])) 
     32    if (!isset($options['choices'])) 
    3333    { 
    34       throw new sfException('The "expected" option is mandatory.'); 
     34      throw new sfException('The "choices" option is mandatory.'); 
    3535    } 
    3636 
     
    4343  protected function doClean($value) 
    4444  { 
    45     if (!in_array($value, $this->getOption('expected'))) 
     45    if (!in_array($value, $this->getOption('choices'))) 
    4646    { 
    4747      throw new sfValidatorError($this, 'invalid', array('value' => $value)); 
     
    5656  protected function getOptionsWithoutDefaults() 
    5757  { 
    58     return parent::getOptionsWithoutDefaults(array('expected' => array('--fake--'))); 
     58    return parent::getOptionsWithoutDefaults(array('choices' => array('--fake--'))); 
    5959  } 
    6060 
     
    6464  protected function getMessagesWithoutDefaults() 
    6565  { 
    66     return parent::getMessagesWithoutDefaults(array('expected' => array('--fake--'))); 
     66    return parent::getMessagesWithoutDefaults(array('choices' => array('--fake--'))); 
    6767  } 
    6868} 
  • trunk/lib/validator/sfValidatorChoiceMany.class.php

    r5753 r5757  
    3131    foreach ($values as $value) 
    3232    { 
    33       if (!in_array($value, $this->getOption('expected'))) 
     33      if (!in_array($value, $this->getOption('choices'))) 
    3434      { 
    3535        throw new sfValidatorError($this, 'invalid', array('value' => $value)); 
  • trunk/test/unit/validator/sfValidatorChoiceManyTest.php

    r5753 r5757  
    1313$t = new lime_test(5, new lime_output_color()); 
    1414 
    15 $v = new sfValidatorChoiceMany(array('expected' => array('foo', 'bar'))); 
     15$v = new sfValidatorChoiceMany(array('choices' => array('foo', 'bar'))); 
    1616 
    1717// ->clean() 
  • trunk/test/unit/validator/sfValidatorChoiceTest.php

    r5753 r5757  
    2525} 
    2626 
    27 $v = new sfValidatorChoice(array('expected' => array('foo', 'bar'))); 
     27$v = new sfValidatorChoice(array('choices' => array('foo', 'bar'))); 
    2828 
    2929// ->clean() 
     
    4444// ->asString() 
    4545$t->diag('->asString()'); 
    46 $t->is($v->asString(), 'Choice({ expected: [foo, bar] })', '->asString() returns a string representation of the validator'); 
     46$t->is($v->asString(), 'Choice({ choices: [foo, bar] })', '->asString() returns a string representation of the validator'); 
  • trunk/test/unit/validator/sfValidatorFromDescriptionTest.php

    r5753 r5757  
    105105  'email:Email and (age:Integer({min: 18}) or (age:Integer({max: 18}) and is_young:Boolean({required: true})))', 
    106106  '(password == password_bis) and begin_date <= end_date and password:String({min: 4, max: 18})', 
    107   'countries:Choice({expected: [France, USA, Italy, Spain]}) and password ==({invalid: "Passwords must be the same (%left_field% != %right_field%)"}) password_bis and begin_date <= end_date and password:String({min: 4, max: 18})', 
     107  'countries:Choice({choices: [France, USA, Italy, Spain]}) and password ==({invalid: "Passwords must be the same (%left_field% != %right_field%)"}) password_bis and begin_date <= end_date and password:String({min: 4, max: 18})', 
    108108); 
    109109