doGetViolations example

$contextualValidator->expects($this->any())
            ->method('validate')
            ->willReturnCallback(fn ($value$constraints = null, $groups = null) => $contextualValidator->doValidate($value$constraints$groups));
        $contextualValidator->expects($this->any())
            ->method('validateProperty')
            ->willReturnCallback(fn ($object$propertyName$groups = null) => $contextualValidator->validateProperty($object$propertyName$groups));
        $contextualValidator->expects($this->any())
            ->method('validatePropertyValue')
            ->willReturnCallback(fn ($objectOrClass$propertyName$value$groups = null) => $contextualValidator->doValidatePropertyValue($objectOrClass$propertyName$value$groups));
        $contextualValidator->expects($this->any())
            ->method('getViolations')
            ->willReturnCallback(fn () => $contextualValidator->doGetViolations());
        $validator->expects($this->any())
            ->method('inContext')
            ->with($context)
            ->willReturn($contextualValidator);

        return $context;
    }

    protected function setGroup(?string $group)
    {
        $this->group = $group;
        
$contextualValidator->expects($this->any())
            ->method('validate')
            ->willReturnCallback(fn ($value$constraints = null, $groups = null) => $contextualValidator->doValidate($value$constraints$groups));
        $contextualValidator->expects($this->any())
            ->method('validateProperty')
            ->willReturnCallback(fn ($object$propertyName$groups = null) => $contextualValidator->validateProperty($object$propertyName$groups));
        $contextualValidator->expects($this->any())
            ->method('validatePropertyValue')
            ->willReturnCallback(fn ($objectOrClass$propertyName$value$groups = null) => $contextualValidator->doValidatePropertyValue($objectOrClass$propertyName$value$groups));
        $contextualValidator->expects($this->any())
            ->method('getViolations')
            ->willReturnCallback(fn () => $contextualValidator->doGetViolations());
        $validator->expects($this->any())
            ->method('inContext')
            ->with($context)
            ->willReturn($contextualValidator);

        return $context;
    }

    protected function setGroup(?string $group)
    {
        $this->group = $group;
        
Home | Imprint | This part of the site doesn't use cookies.