Example #1
0
 function it_looks_for_an_email_in_configuration_when_it_cannot_be_found_via_repository(EmailInterface $email, EmailFactoryInterface $emailFactory)
 {
     $emailFactory->createNew()->willReturn($email);
     $email->setCode('user_confirmation')->shouldBeCalled();
     $email->setSubject('Hello test!')->shouldBeCalled();
     $email->setTemplate('SyliusMailerBundle::default.html.twig')->shouldBeCalled();
     $email->setSenderName('John Doe')->shouldBeCalled();
     $email->setSenderAddress('*****@*****.**')->shouldBeCalled();
     $email->setEnabled(false)->shouldBeCalled();
     $this->getEmail('user_confirmation')->shouldReturn($email);
 }
Example #2
0
 /**
  * @param string $code
  *
  * @return EmailInterface
  */
 private function getEmailFromConfiguration($code)
 {
     Assert::keyExists($this->configuration, $code, sprintf('Email with code "%s" does not exist!', $code));
     /** @var EmailInterface $email */
     $email = $this->emailFactory->createNew();
     $configuration = $this->configuration[$code];
     $email->setCode($code);
     $email->setSubject($configuration['subject']);
     $email->setTemplate($configuration['template']);
     if (isset($configuration['enabled']) && false === $configuration['enabled']) {
         $email->setEnabled(false);
     }
     if (isset($configuration['sender']['name'])) {
         $email->setSenderName($configuration['sender']['name']);
     }
     if (isset($configuration['sender']['address'])) {
         $email->setSenderAddress($configuration['sender']['address']);
     }
     return $email;
 }