Changeset 7044
- Timestamp:
- 01/14/08 12:15:55 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/validator/sfValidatorErrorSchema.class.php
r6963 r7044 107 107 public function addErrors($errors) 108 108 { 109 foreach ($errors as $name => $error)109 if ($errors instanceof sfValidatorErrorSchema) 110 110 { 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 } 112 127 } 113 128 } branches/1.1/test/unit/validator/sfValidatorErrorSchemaTest.php
r6964 r7044 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(2 4, new lime_output_color());13 $t = new lime_test(26, new lime_output_color()); 14 14 15 15 $v1 = new sfValidatorString(); … … 51 51 $es->addError($es2, 'e2'); 52 52 $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'); 53 63 54 64 // ->getGlobalErrors()

