コード例 #1
0
 public function testShouldRenderTwigParts()
 {
     $twig = $this->prophesize(\Twig_Environment::class);
     $twig->render('template.twig.html', [])->shouldBeCalled();
     $processor = new TwigProcessor($twig->reveal());
     $email = new Email();
     $email->addTo('*****@*****.**')->addPart(Email\TwigTemplatePart::create('template.twig.html'), 'text/html');
     $processor->onPreNotify(new PreNotifyEvent($email));
 }
コード例 #2
0
 public function testShouldAddRecipientVariables()
 {
     $that = $this;
     $this->mailgun->sendMessage('www.example.org', Argument::type('array'), Argument::cetera())->shouldBeCalled()->will(function ($args) use($that) {
         $postData = $args[1];
         $that->assertArrayHasKey('recipient-variables', $postData);
         $that->assertJson($postData['recipient-variables']);
         $resp = new \stdClass();
         $resp->http_response_code = 200;
         return $resp;
     });
     $this->handler->notify(Email::create()->addVariablesForRecipient('*****@*****.**', ['key' => 'value'])->addTo('*****@*****.**'));
 }
コード例 #3
0
 public function testShouldSkipNotSupportedHandlers()
 {
     $notification = Email::create();
     $handler = $this->prophesize(NotificationHandlerInterface::class);
     $handler->getName()->willReturn('swiftmailer');
     $handler->supports(Argument::any())->willReturn(false);
     $handler->notify(Argument::any())->shouldNotBeCalled();
     $handler2 = $this->prophesize(NotificationHandlerInterface::class);
     $handler2->getName()->willReturn('default');
     $handler2->supports(Argument::any())->willReturn(true);
     $handler2->notify(Argument::any())->shouldBeCalled();
     $this->manager->addHandler($handler->reveal());
     $this->manager->addHandler($handler2->reveal());
     $this->manager->notify($notification);
 }
コード例 #4
0
 /**
  * Adds the {@see Email::additionalHeaders} to the message.
  *
  * @param Email $notification
  * @param \Swift_Message $email
  */
 protected function addHeaders(Email $notification, \Swift_Message $email)
 {
     $headers = $email->getHeaders();
     foreach ($notification->getAdditionalHeaders() as $key => $value) {
         if ($value instanceof \DateTime) {
             $headers->addDateHeader($key, $value);
         } else {
             $headers->addTextHeader($key, $value);
         }
     }
 }
コード例 #5
0
 public function testShouldSetMultipartAlternativeIfEmailIsMultipart()
 {
     $email = new Email();
     $email->addPart(Email\Part::create('BODY PART', 'text/plain'))->addPart(Email\Part::create('PART 2', 'text/html'));
     $this->mailer->send(Argument::that(function ($argument) {
         if (!$argument instanceof \Swift_Message) {
             return false;
         }
         $this->assertCount(2, $argument->getChildren());
         $this->assertEquals('multipart/alternative', $argument->getContentType());
         return true;
     }))->willReturn(1);
     $this->handler->notify($email);
 }
コード例 #6
0
ファイル: EmailTest.php プロジェクト: fazland/notifire
 /**
  * @expectedException \Fazland\Notifire\Exception\PartContentTypeMismatchException
  */
 public function testAddPartShouldThrowIfTwoPartsWithSameContentTypeHasAdded()
 {
     Email::create()->addPart(Email\Part::create('BlaBla', 'text/html'))->addPart(Email\Part::create('Foo bar', 'text/html'));
 }