public function testAddErrors()
 {
     //ForceAppend === false
     $object = new CopixErrorObject(array(0 => 'Erreur1', 1 => 'Erreur2'));
     $object->addErrors(array(1 => 'Erreur2'));
     $this->assertEquals(count($object->asArray()), 2);
     //ForceAppend = true
     $object->addErrors(array(1 => 'Erreur3'), true);
     $this->assertEquals(count($object->asArray()), 3);
     //Ajout d'un errorObject (forceappend == false)
     $object2 = new CopixErrorObject(array(0 => 'Erreur1', 1 => 'Erreur2'));
     $object->addErrors($object2);
     $this->assertEquals(count($object->asArray()), 3);
     //Ajout d'un errorObject (forceappend == true)
     $object2 = new CopixErrorObject(array(0 => 'Erreur4', 1 => 'Erreur5'));
     $object->addErrors($object2, true);
     $this->assertEquals(count($object->asArray()), 5);
     //Ajout d'un StdClass (forceappend === false)
     $object = new CopixErrorObject(array('e1' => 'Erreur1'));
     $errors = new StdClass();
     $errors->e1 = 'Erreur 1';
     $object->addErrors($errors);
     $this->assertEquals(count($object->asArray()), 1);
     //Ajout d'un StdClass (forceappend === true)
     $errors->e1 = 'Erreur 2';
     $object->addErrors($errors, true);
     $this->assertEquals(count($object->asArray()), 2);
 }
 function check()
 {
     $errorObject = new CopixErrorObject();
     if (strlen($this->worker_id) <= 0) {
         $errorObject->addError('worker_id', CopixI18N::get('copix:dao.errors.required', 'Worker id'));
     }
     if (strlen($this->branch_id) <= 0) {
         $errorObject->addError('branch_id', CopixI18N::get('copix:dao.errors.required', 'Branch id'));
     }
     return $errorObject->isError() ? $errorObject->asArray() : true;
 }
 /**
  * On passe par toutes les méthodes de validation intermédiaire
  * @param mixed $pValue La propriété à valider
  * @return boolean / CopixErrorObject
  */
 protected function _validate($pValue)
 {
     $toReturn = new CopixErrorObject();
     foreach ($this->_propertiesToCheck() as $propertyName) {
         if (($result = $this->_checkProperty($propertyName, $pValue)) !== true) {
             $toReturn->addErrors(array($propertyName => $result));
         }
     }
     return $toReturn->isError() ? new CopixErrorObject($this->_getMessage($pValue, $toReturn)) : true;
 }
 function check()
 {
     $errorObject = new CopixErrorObject();
     return $errorObject->isError() ? $errorObject->asArray() : true;
 }
 /**
  * Checks if we can send an email with the given configuration.
  */
 public function check()
 {
     $error = new CopixErrorObject();
     if ($this->to === null) {
         $error->addError('to', 'Aucune valeur donnée à destinataire.');
     }
     if ($this->from === null) {
         $error->addError('from', 'Aucune valeur expéditeur');
     }
     return $error;
 }