public function testModel()
 {
     $template = 'template_name';
     $variables = array('foo' => 'bar');
     $type = MailTypes::TYPE_ALL;
     $event = new FilterPreRenderEvent($template, $variables, $type);
     $this->assertSame($template, $event->getTemplate());
     $this->assertSame($variables, $event->getVariables());
     $this->assertSame($type, $event->getType());
     $template2 = 'new_template_name';
     $variables2 = array_merge($variables, array('bar' => 'foo'));
     $type2 = MailTypes::TYPE_SCREEN;
     $event->setTemplate($template2);
     $event->setVariables($variables2);
     $event->setType($type2);
     $this->assertSame($template2, $event->getTemplate());
     $this->assertSame($variables2, $event->getVariables());
     $this->assertSame($type2, $event->getType());
 }
 /**
  * Render the mail.
  *
  * @param FilterPreRenderEvent $preEvent The template pre event
  * @param MailInterface        $mail     The mail
  *
  * @return MailRendered
  */
 protected function doRender(FilterPreRenderEvent $preEvent, MailInterface $mail)
 {
     $variables = $preEvent->getVariables();
     $variables['_mail_type'] = $mail->getType();
     $variables['_layout'] = null !== $mail->getLayout() ? $mail->getLayout()->getName() : null;
     $subject = $this->renderTemplate($mail->getSubject(), $mail, $variables);
     $variables['_subject'] = $subject;
     $htmlBody = $this->renderTemplate($mail->getHtmlBody(), $mail, $variables);
     $variables['_html_body'] = $htmlBody;
     $body = $this->renderTemplate($mail->getBody(), $mail, $variables);
     $variables['_body'] = $body;
     $layout = $this->getTranslatedLayout($mail);
     if (null !== $layout && null !== ($lBody = $layout->getBody()) && !MailUtil::isRootBody($htmlBody)) {
         $htmlBody = $this->renderTemplate($lBody, $layout, $variables);
     }
     return new MailRendered($mail, $subject, $htmlBody, $body);
 }