Example #1
0
 /**
  * @param object $entity
  *
  * @return null|object
  */
 protected function validateAndUpdateContext($entity)
 {
     // validate entity
     $validationErrors = $this->strategyHelper->validateEntity($entity);
     if ($validationErrors) {
         $this->context->incrementErrorEntriesCount();
         $errorPrefix = ValidationUtils::guessValidationMessagePrefix($entity);
         $this->strategyHelper->addValidationErrors($validationErrors, $this->context, $errorPrefix);
         return null;
     }
     // increment context counter
     if ($entity->getId()) {
         $this->context->incrementUpdateCount();
     } else {
         $this->context->incrementAddCount();
     }
     return $entity;
 }
Example #2
0
 /**
  * @dataProvider entityProvider
  *
  * @param object $entity
  * @param string $shouldContain
  */
 public function testErrorPrefixGuess($entity, $shouldContain)
 {
     $this->assertContains((string) $shouldContain, ValidationUtils::guessValidationMessagePrefix($entity));
 }