EntityParent example

$this->assertInstanceOf(NotNull::class$violations->get(0)->getConstraint());
        $this->assertInstanceOf(IsTrue::class$violations->get(1)->getConstraint());
    }

    public function testValidConstraintOnGetterReturningNull()
    {
        $metadata = new ClassMetadata(EntityParent::class);
        $metadata->addGetterConstraint('child', new Valid());

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

        $violations = $this->validator->validate(new EntityParent());

        $this->assertCount(0, $violations);
    }

    public function testNotNullConstraintOnGetterReturningNull()
    {
        $metadata = new ClassMetadata(EntityParent::class);
        $metadata->addGetterConstraint('child', new NotNull());

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

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