/** * @param \Symfony\Component\Validator\Constraint $constraint */ protected function validate(Constraint $constraint) { $subPath = (string) $this->getCurrentPropertyPath(); if ($this->context instanceof LegacyExecutionContextInterface) { $this->context->validateValue($this->getValue(), $constraint, $subPath, $this->group); } else { $this->context->getValidator()->inContext($this->context)->atPath($subPath)->validate($this->getValue(), $constraint, array($this->group)); } }
function it_does_not_validate_false_condition($constraint, NewContext $context, ValidatorInterface $validator, ContextualValidatorInterface $contextValidator) { $constraint->condition = function () { return false; }; $context->getObject()->shouldBeCalled(); $context->getValidator()->shouldNotBeCalled(); $context->validateValue(Argument::any(), Argument::any(), Argument::any(), Argument::any())->shouldNotBeCalled(); $this->initialize($context); $this->validate('some value', $constraint); }