function it_can_be_transformed(EngineInterface $templating, FilterChainInterface $filterChain, MailUserInterface $recipient1, MailUserInterface $recipient2, Attachment $attachment)
 {
     $html = '<html><head></head><body>Test</body></html>';
     $templating->render(Argument::type('string'), Argument::type('array'))->willReturn($html);
     $filterChain->apply(Argument::type('string'), Argument::any())->willReturn($html);
     $recipient1->getFullName()->willReturn('Test recipient 1');
     $recipient1->getEmail()->willReturn('*****@*****.**');
     $recipient2->getFullName()->willReturn('Test recipient 2');
     $recipient2->getEmail()->willReturn('*****@*****.**');
     $attachmentFileName = 'test.txt';
     $attachment->getData()->willReturn('test');
     $attachment->getFilename()->willReturn($attachmentFileName);
     $attachment->getContentType()->willReturn('text');
     $this->addRecipients([$recipient1, $recipient2]);
     $this->addBccRecipients([$recipient1, $recipient2]);
     $this->addAttachment($attachment);
     $message = $this->transform($templating, $filterChain, array(array('view' => 'default', 'contentType' => 'text/html')));
     $message->shouldHaveType('\\Swift_Message');
     $message->getSubject()->shouldBeLike(self::SUBJECT);
     $message->getBody()->shouldBeLike($html);
     $message->getFrom()->shouldBeLike(array(self::SENDER_EMAIL => self::SENDER_NAME));
     $message->getTo()->shouldHaveCount(2);
     $message->getBcc()->shouldHaveCount(2);
     $message->getChildren()->shouldHaveCount(1);
     // 1 attachment
     $attachment = $message->getChildren()[0];
     $attachment->shouldHaveType('Swift_Mime_Attachment');
     $attachment->getFileName()->shouldBeLike($attachmentFileName);
 }
 function it_can_be_transformed(EngineInterface $templating, FilterChainInterface $filterChain)
 {
     $html = '<html><head></head><body>Test</body></html>';
     $templating->render(Argument::type('string'), Argument::type('array'))->willReturn($html);
     $filterChain->apply(Argument::type('string'), Argument::any())->willReturn($html);
     $message = $this->transform($templating, $filterChain, array(array('view' => 'default', 'contentType' => 'text/html')));
     $message->shouldHaveType('\\Swift_Message');
     $message->getSubject()->shouldBeLike(self::SUBJECT);
     $message->getBody()->shouldBeLike($html);
     $message->getFrom()->shouldBeLike(array(self::SENDER_EMAIL => self::SENDER_NAME));
     $message->getTo()->shouldBeLike(array(self::RECIPIENT_EMAIL => self::RECIPIENT_NAME));
 }
 /**
  * {@inheritdoc}
  */
 public function transform(EngineInterface $templating, FilterChainInterface $filterChain, array $templates)
 {
     $message = $this->createSwiftMessage();
     $message->setTo($this->recipient->getEmail(), $this->recipient->getFullName());
     $body = $templating->render($templates[0]['view'], $this->parameters);
     $body = $filterChain->apply($body, $message);
     $message->setBody($body, $templates[0]['contentType']);
     for ($i = 1; $i < count($templates); $i++) {
         $part = $templating->render($templates[$i]['view'], $this->parameters);
         $part = $filterChain->apply($part, $message);
         $message->addPart($part, $templates[$i]['contentType']);
     }
     return $message;
 }
 /**
  * {@inheritdoc}
  */
 public function transform(EngineInterface $templating, FilterChainInterface $filterChain, array $templates)
 {
     $message = $this->createSwiftMessage();
     foreach ($this->recipients as $recipient) {
         $message->addTo($recipient->getEmail(), $recipient->getFullName());
     }
     foreach ($this->bccRecipients as $recipient) {
         $message->addBcc($recipient->getEmail(), $recipient->getFullName());
     }
     foreach ($this->attachments as $attachment) {
         $message->attach(\Swift_Attachment::newInstance($attachment->getData(), $attachment->getFilename(), $attachment->getContentType()));
     }
     $message->setContentType($templates[0]['contentType']);
     $body = $templating->render($templates[0]['view'], $this->parameters);
     $body = $filterChain->apply($body, $message);
     $message->setBody($body);
     for ($i = 1; $i < count($templates); $i++) {
         $body = $templating->render($templates[$i]['view'], $this->parameters);
         $body = $filterChain->apply($body, $message);
         $message->addPart($body, $templates[$i]['contentType']);
     }
     return $message;
 }