Development

Changeset 7044

You must first sign up to be able to contribute.

Changeset 7044

Show
Ignore:
Timestamp:
01/14/08 12:15:55 (9 months ago)
Author:
fabien
Message:

fixed sfValidatorErrorSchema::addErrors() when an error has an integer name

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/validator/sfValidatorErrorSchema.class.php

    r6963 r7044  
    107107  public function addErrors($errors) 
    108108  { 
    109     foreach ($errors as $name => $error
     109    if ($errors instanceof sfValidatorErrorSchema
    110110    { 
    111       $this->addError($error, $name); 
     111      foreach ($errors->getGlobalErrors() as $error) 
     112      { 
     113        $this->addError($error); 
     114      } 
     115 
     116      foreach ($errors->getNamedErrors() as $name => $error) 
     117      { 
     118        $this->addError($error, (string) $name); 
     119      } 
     120    } 
     121    else 
     122    { 
     123      foreach ($errors as $name => $error) 
     124      { 
     125        $this->addError($error, $name); 
     126      } 
    112127    } 
    113128  } 
  • branches/1.1/test/unit/validator/sfValidatorErrorSchemaTest.php

    r6964 r7044  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(24, new lime_output_color()); 
     13$t = new lime_test(26, new lime_output_color()); 
    1414 
    1515$v1 = new sfValidatorString(); 
     
    5151$es->addError($es2, 'e2'); 
    5252$t->is($es->getCode(), 'max_length e1 [max_length] e2 [max_length max_length e1 [max_length max_length] e2 [min_length max_length e1 [max_length] e2 [min_length]]]', '->addError() adds an error to the error schema'); 
     53 
     54// ->addErrors() 
     55$t->diag('->addErrors()'); 
     56$es1 = new sfValidatorErrorSchema($v1); 
     57$es1->addError($e1); 
     58$es1->addError($e2, '1'); 
     59$es = new sfValidatorErrorSchema($v1); 
     60$es->addErrors($es1); 
     61$t->is($es->getGlobalErrors(), array($e1), '->addErrors() adds an array of errors to the current error'); 
     62$t->is($es->getNamedErrors(), array('1' => $e2), '->addErrors() merges a sfValidatorErrorSchema to the current error'); 
    5363 
    5464// ->getGlobalErrors()