/**
  * Adds a collection of errors.
  *
  * @param sfValidatorErrorSchema $errorsAn sfValidatorErrorSchema instance
  *
  * @return sfValidatorErrorSchema The current error schema instance
  */
 public function addErrors(sfValidatorErrorSchema $errors)
 {
     foreach ($errors->getGlobalErrors() as $error) {
         $this->addError($error);
     }
     foreach ($errors->getNamedErrors() as $name => $error) {
         $this->addError($error, $name);
     }
     return $this;
 }
$t->diag('implements Serializable');
class NotSerializable implements Serializable
{
    public function serialize()
    {
        throw new Exception('Not serializable');
    }
    public function unserialize($serialized)
    {
        throw new Exception('Not serializable');
    }
}
function will_crash($a)
{
    return serialize(new sfValidatorErrorSchema(new sfValidatorString()));
}
$a = new NotSerializable();
try {
    $serialized = will_crash($a);
    $t->pass('"sfValidatorErrorSchema" implements Serializable');
} catch (Exception $e) {
    $t->fail('"sfValidatorErrorSchema" implements Serializable');
}
$e = new sfValidatorErrorSchema($v1);
$e1 = unserialize($serialized);
$t->is($e1->getMessage(), $e->getMessage(), '"sfValidatorErrorSchema" implements Serializable');
$t->is($e1->getCode(), $e->getCode(), '"sfValidatorErrorSchema" implements Serializable');
$t->is(get_class($e1->getValidator()), get_class($e->getValidator()), '"sfValidatorErrorSchema" implements Serializable');
$t->is($e1->getArguments(), $e->getArguments(), '"sfValidatorErrorSchema" implements Serializable');
$t->is($e1->getNamedErrors(), $e->getNamedErrors(), '"sfValidatorErrorSchema" implements Serializable');
$t->is($e1->getGlobalErrors(), $e->getGlobalErrors(), '"sfValidatorErrorSchema" implements Serializable');
$t->is($es->getCode(), 'max_length min_length e1 [max_length min_length] e2 [max_length e1 [max_length] e2 [min_length]] e3 [max_length e1 [max_length] e2 [min_length]]', '->addError() adds an error to the error schema');
$es->addError($es1);
$t->is($es->getCode(), 'max_length min_length max_length e1 [max_length min_length max_length] e2 [max_length min_length e1 [max_length] e2 [min_length]] e3 [max_length e1 [max_length] e2 [min_length]]', '->addError() adds an error to the error schema');
$es = new sfValidatorErrorSchema($v1, array($e1, 'e1' => $e1, 'e2' => $es1));
$es2 = new sfValidatorErrorSchema($v1, array($e1, 'e1' => $e1, 'e2' => $es1));
$es->addError($es2, 'e2');
$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');
// ->addErrors()
$t->diag('->addErrors()');
$es1 = new sfValidatorErrorSchema($v1);
$es1->addError($e1);
$es1->addError($e2, '1');
$es = new sfValidatorErrorSchema($v1);
$es->addErrors($es1);
$t->is($es->getGlobalErrors(), array($e1), '->addErrors() adds an array of errors to the current error');
$t->is($es->getNamedErrors(), array('1' => $e2), '->addErrors() merges a sfValidatorErrorSchema to the current error');
// ->getGlobalErrors()
$t->diag('->getGlobalErrors()');
$e = new sfValidatorErrorSchema($v1);
$e->addError($e1);
$e->addError($e2, 'e2');
$e->addError($e1, '2');
$t->is($e->getGlobalErrors(), array($e1), '->getGlobalErrors() returns all globals/non named errors');
// ->getNamedErrors()
$t->diag('->getNamedErrors()');
$t->is($e->getNamedErrors(), array('e2' => $e2, '2' => $e1), '->getNamedErrors() returns all named errors');
// ->getValue()
$t->diag('->getValue()');
$t->is($e->getValue(), null, '->getValue() always returns null');
// ->getArguments()
$t->diag('->getArguments()');