Ejemplo n.º 1
0
 public function testValidateInvalidValue()
 {
     $value = 123;
     $constraint = new EntityClass();
     $context = $this->getMockBuilder('Symfony\\Component\\Validator\\ExecutionContext')->disableOriginalConstructor()->getMock();
     $context->expects($this->once())->method('addViolation')->with($constraint->message, ['{{ value }}' => '123']);
     $this->validator->initialize($context);
     $this->validator->validate($value, $constraint);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function formatValue($value, $format = 0)
 {
     if (is_array($value) && array_key_exists('id', $value) && array_key_exists('entity', $value)) {
         return sprintf('[id => %s, entity => %s]', $this->formatValue($value['id']), $this->formatValue($value['entity']));
     }
     return parent::formatValue($value, $format);
 }