public function testExecuteWithInvalidEmail() { $this->setExpectedException('\\Symfony\\Component\\Validator\\Exception\\ValidatorException', 'test'); $options = ['from' => 'invalidemailaddress', 'to' => '*****@*****.**', 'template' => 'test', 'subject' => 'subject', 'body' => 'body', 'entity' => new \stdClass()]; $context = []; $this->contextAccessor->expects($this->any())->method('getValue')->will($this->returnArgument(1)); $this->entityNameResolver->expects($this->any())->method('getName')->will($this->returnCallback(function () { return '_Formatted'; })); $violationList = $this->getMockBuilder('Symfony\\Component\\Validator\\ConstraintViolationList')->disableOriginalConstructor()->getMock(); $violationList->expects($this->once())->method('count')->willReturn(1); $violationListInterface = $this->getMockBuilder('Symfony\\Component\\Validator\\ConstraintViolationInterface')->disableOriginalConstructor()->getMock(); $violationListInterface->expects($this->once())->method('getMessage')->willReturn('test'); $violationList->expects($this->once())->method('get')->willReturn($violationListInterface); $this->validator->expects($this->once())->method('validate')->willReturn($violationList); $this->objectRepository->expects($this->never())->method('findByName')->with($options['template'])->willReturn($this->emailTemplate); $this->emailTemplate->expects($this->never())->method('getType')->willReturn('txt'); $this->renderer->expects($this->never())->method('compileMessage')->willReturn([$options['subject'], $options['body']]); $emailEntity = $this->getMockBuilder('\\Oro\\Bundle\\EmailBundle\\Entity\\Email')->disableOriginalConstructor()->getMock(); $this->emailProcessor->expects($this->never())->method('process'); if (array_key_exists('attribute', $options)) { $this->contextAccessor->expects($this->once())->method('setValue')->with($context, $options['attribute'], $emailEntity); } $this->action->initialize($options); $this->action->execute($context); }