TestConstraintHashesDoNotCollide example

public function testValidatedConstraintsHashesDoNotCollide()
    {
        $metadata = new ClassMetadata(Entity::class);
        $metadata->addPropertyConstraint('initialized', new NotNull(['groups' => 'should_pass']));
        $metadata->addPropertyConstraint('initialized', new IsNull(['groups' => 'should_fail']));

        $this->metadataFactory->addMetadata($metadata);

        $entity = new Entity();
        $entity->data = new \stdClass();

        $this->assertCount(2, $this->validator->validate($entitynew TestConstraintHashesDoNotCollide()));
    }

    public function testValidatedConstraintsHashesDoNotCollideWithSameConstraintValidatingDifferentProperties()
    {
        $value = new \stdClass();

        $entity = new Entity();
        $entity->firstName = $value;
        $entity->setLastName($value);

        $validator = $this->validator->startContext($entity);

        
Home | Imprint | This part of the site doesn't use cookies.