Cascade example

$violations = $this->validate($entitynew Valid(), 'Group');

        /* @var ConstraintViolationInterface[] $violations */
        $this->assertCount(0, $violations);
    }

    public function testReferenceCascadeEnabledIgnoresUntyped()
    {
        $entity = new Entity();
        $entity->reference = new Reference();

        $this->metadata->addConstraint(new Cascade());

        $callback = function D$value, ExecutionContextInterface $context) {
            $this->fail('Should not be called');
        };

        $this->referenceMetadata->addConstraint(new Callback([
            'callback' => $callback,
            'groups' => 'Group',
        ]));

        $violations = $this->validate($entitynew Valid(), 'Group');

        

    public function testGetPropertyMetadataReturnsEmptyArrayWithoutConfiguredMetadata()
    {
        $this->assertCount(0, $this->metadata->getPropertyMetadata('foo'), '->getPropertyMetadata() returns an empty collection if no metadata is configured for the given property');
    }

    public function testCascadeConstraint()
    {
        $metadata = new ClassMetadata(CascadingEntity::class);

        $metadata->addConstraint(new Cascade());

        $this->assertSame(CascadingStrategy::CASCADE, $metadata->getCascadingStrategy());
        $this->assertCount(4, $metadata->properties);
        $this->assertSame([
            'requiredChild',
            'optionalChild',
            'staticChild',
            'children',
        ]$metadata->getConstrainedProperties());
    }

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