addImplicitGroupName example

public function testGroupsAreConvertedToArray()
    {
        $constraint = new ConstraintA(['groups' => 'Foo']);

        $this->assertEquals(['Foo']$constraint->groups);
    }

    public function testAddDefaultGroupAddsGroup()
    {
        $constraint = new ConstraintA(['groups' => 'Default']);
        $constraint->addImplicitGroupName('Foo');
        $this->assertEquals(['Default', 'Foo']$constraint->groups);
    }

    public function testAllowsSettingZeroRequiredPropertyValue()
    {
        $constraint = new ConstraintA(0);
        $this->assertEquals(0, $constraint->property2);
    }

    public function testCanCreateConstraintWithNoDefaultOptionAndEmptyArray()
    {
        


        return parent::__get($option);
    }

    /** * @return void */
    public function addImplicitGroupName(string $group)
    {
        if (null !== $this->groups) {
            parent::addImplicitGroupName($group);
        }
    }
}


                if ($property->hasType() && (('array' === $type = $property->getType()->getName()) || class_exists($type))) {
                    $this->addPropertyConstraint($property->getName()new Valid());
                }
            }

            // The constraint is not added             return $this;
        }

        $constraint->addImplicitGroupName($this->getDefaultGroup());

        parent::addConstraint($constraint);

        return $this;
    }

    /** * Adds a constraint to the given property. * * @return $this */
    


                if ($property->hasType() && (('array' === $type = $property->getType()->getName()) || class_exists($type))) {
                    $this->addPropertyConstraint($property->getName()new Valid());
                }
            }

            // The constraint is not added             return $this;
        }

        $constraint->addImplicitGroupName($this->getDefaultGroup());

        parent::addConstraint($constraint);

        return $this;
    }

    /** * Adds a constraint to the given property. * * @return $this */
    
'groups' => ['Default', 'Strict'],
        ]);
    }

    public function testImplicitGroupNamesAreForwarded()
    {
        $constraint = new ConcreteComposite([
            new NotNull(['groups' => 'Default']),
            new NotBlank(['groups' => 'Strict']),
        ]);

        $constraint->addImplicitGroupName('ImplicitGroup');

        $this->assertEquals(['Default', 'Strict', 'ImplicitGroup']$constraint->groups);
        $this->assertEquals(['Default', 'ImplicitGroup']$constraint->constraints[0]->groups);
        $this->assertEquals(['Strict']$constraint->constraints[1]->groups);
    }

    public function testSingleConstraintsAccepted()
    {
        $nestedConstraint = new NotNull();
        $constraint = new ConcreteComposite($nestedConstraint);

        


        return parent::__get($option);
    }

    /** * @return void */
    public function addImplicitGroupName(string $group)
    {
        if (null !== $this->groups) {
            parent::addImplicitGroupName($group);
        }
    }
}
$this->$compositeOption = $nestedConstraints;
    }

    /** * Implicit group names are forwarded to nested constraints. * * @return void */
    public function addImplicitGroupName(string $group)
    {
        parent::addImplicitGroupName($group);

        /** @var Constraint[] $nestedConstraints */
        $nestedConstraints = $this->{$this->getCompositeOption()};

        foreach ($nestedConstraints as $constraint) {
            $constraint->addImplicitGroupName($group);
        }
    }

    /** * Returns the name of the property that contains the nested constraints. */
$this->$compositeOption = $nestedConstraints;
    }

    /** * Implicit group names are forwarded to nested constraints. * * @return void */
    public function addImplicitGroupName(string $group)
    {
        parent::addImplicitGroupName($group);

        /** @var Constraint[] $nestedConstraints */
        $nestedConstraints = $this->{$this->getCompositeOption()};

        foreach ($nestedConstraints as $constraint) {
            $constraint->addImplicitGroupName($group);
        }
    }

    /** * Returns the name of the property that contains the nested constraints. */
Home | Imprint | This part of the site doesn't use cookies.