public function AbstractValidatorTest::testValidateDifferentObjectsSeparately in Plug 7
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Tests/ Validator/ AbstractValidatorTest.php, line 1021
Class
- AbstractValidatorTest
- @since 2.5 @author Bernhard Schussek <bschussek@gmail.com>
Namespace
Symfony\Component\Validator\Tests\ValidatorCode
public function testValidateDifferentObjectsSeparately() {
$entity = new Entity();
$entity->reference = new Reference();
$entity->reference2 = new Reference();
$callback = function ($value, ExecutionContextInterface $context) {
$context
->addViolation('Message');
};
$this->metadata
->addPropertyConstraint('reference', new Valid());
$this->metadata
->addPropertyConstraint('reference2', new Valid());
$this->referenceMetadata
->addConstraint(new Callback($callback));
$violations = $this
->validate($entity);
/** @var ConstraintViolationInterface[] $violations */
$this
->assertCount(2, $violations);
}