예제 #1
0
 /**
  * @dataProvider getDataForTestSendMail
  *
  * @param null|string $to
  * @param null|string $from
  * @param null|string $subject
  * @param null|string $body
  * @param array       $cc
  * @param null|string $attachmentName
  * @param null|string $attachmentPath
  */
 public function testSendMail($to, $from, $subject, $body, $cc, $attachmentName, $attachmentPath)
 {
     $this->message->getTo()->shouldBeCalledTimes(2)->willReturn($to);
     $this->message->getFrom()->shouldBeCalledTimes(2)->willReturn($from);
     $this->message->getSubject()->shouldBeCalledTimes(2)->willReturn($subject);
     $this->message->getBody()->shouldBeCalledTimes(1)->willReturn($body);
     $getCcCalls = count($cc) > 0 ? 2 : 1;
     $this->message->getCc()->shouldBeCalledTimes($getCcCalls)->willReturn($cc);
     $getAttachmentPathCalls = $attachmentPath ? $attachmentName ? 2 : 1 : 1;
     $this->message->getAttachmentPath()->shouldBeCalledTimes($getAttachmentPathCalls)->willReturn($attachmentPath);
     $getAttachmentNameCalls = $attachmentPath ? $attachmentName ? 2 : 1 : 0;
     $this->message->getAttachmentName()->shouldBeCalledTimes($getAttachmentNameCalls)->willReturn($attachmentName);
     $this->logger->info(sprintf(SwiftMailer::INFO_LOG_MESSAGE, $from, $to, $subject), ['SwiftMailer'])->shouldBeCalledTimes(1);
     $this->class->sendMail($this->message->reveal());
 }
예제 #2
0
 /**
  * @dataProvider getDataForTestSendMail
  *
  * @param null|string $type
  * @param null|string $to
  * @param array       $params
  * @param null|string $filename
  */
 public function testSendMail($type, $to, $params, $filename)
 {
     if (!$to && $type) {
         $this->provider->getTo($type)->shouldBeCalled();
     }
     if ($type) {
         $this->provider->getSubject($type, $params)->shouldBeCalled();
         $this->provider->getFrom($type)->shouldBeCalled();
         $this->provider->getBody($type, $params)->shouldBeCalled();
     }
     $this->provider->getCc($type)->shouldBeCalled();
     if (!$filename) {
         $this->provider->getAttachment($type)->shouldBeCalled();
     }
     $this->class->sendMail($type, $to, $params, $filename);
 }