Exemplo n.º 1
0
 public function testSendWithoutTemplate()
 {
     $message = $this->getMockBuilder(\Swift_Message::class)->disableOriginalConstructor()->getMock();
     $this->templater->expects($this->never())->method('render');
     $this->transport->expects($this->once())->method('send')->with($message, null)->will($this->returnValue(true));
     $res = $this->mailer->send('test', $message);
     $this->assertTrue($res);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function send($transport, $message, $template = null, array $variables = array(), $type = MailTypes::TYPE_ALL)
 {
     $transportName = $transport;
     $transport = $this->getTransport($transport);
     $mailRendered = null !== $template ? $this->templater->render($template, $variables, $type) : null;
     $preEvent = new FilterPreSendEvent($transportName, $message, $mailRendered);
     $this->dispatcher->dispatch(MailerEvents::TRANSPORT_PRE_SEND, $preEvent);
     $res = $transport->send($preEvent->getMessage(), $preEvent->getMailRendered());
     $postEvent = new FilterPostSendEvent($res, $transportName, $message, $mailRendered);
     $this->dispatcher->dispatch(MailerEvents::TRANSPORT_POST_SEND, $postEvent);
     return $res;
 }
 /**
  * @param bool $clone
  *
  * @return array
  */
 public function getConfig($clone = false)
 {
     $template = 'test';
     $variables = array('foo' => 'bar');
     $mail = $this->getMockBuilder(MailRenderedInterface::class)->getMock();
     $this->templater->expects($this->at(0))->method('render')->with($template, $variables, MailTypes::TYPE_ALL)->will($this->returnValue($mail));
     if ($clone) {
         $this->templater->expects($this->at(1))->method('render')->with($template, $variables, MailTypes::TYPE_ALL)->will($this->returnValue(clone $mail));
     }
     return array($template, $variables, $mail);
 }