protected function setUp() { $this->constraint = new Email(); $this->context = $this->getMock('Symfony\\Component\\Validator\\ExecutionContextInterface'); $this->validator = new EmailValidator(); $this->validator->initialize($this->context); }
/** * {@inheritdoc} * * @param string|array $value * @param Constraint $constraint */ public function validate($value, Constraint $constraint) { if (is_scalar($value)) { $value = [$value]; } $emailValidator = new EmailValidator(); $emailValidator->initialize($this->context); foreach ($value as $fullEmailAddress) { $email = $this->emailAddressHelper->extractPureEmailAddress($fullEmailAddress); if (!$email) { continue; } $emailValidator->validate($email, $constraint); if ($this->context->getViolations()->count()) { foreach ($this->context->getViolations() as $violation) { /** @var ConstraintViolation $violation */ if ($violation->getPropertyPath() == $this->context->getPropertyPath()) { return; } } } } }