public function testModel() { /* @var LayoutInterface $layout */ $layout = $this->getMockBuilder(LayoutInterface::class)->getMock(); /* @var MailTranslationInterface $translation */ $translation = $this->getMockBuilder(MailTranslationInterface::class)->getMock(); $mail = new Mail(); $mail->setType(MailTypes::TYPE_PRINT)->setSubject('Subject of template')->setHtmlBody('HTML Body of template')->setBody('Body of template')->setLayout($layout)->setTranslationDomain('domain'); $this->assertTrue(is_array($mail->getTranslations())); $this->assertCount(0, $mail->getTranslations()); $mail->addTranslation($translation); $this->assertCount(1, $mail->getTranslations()); $mail->removeTranslation($translation); $this->assertCount(0, $mail->getTranslations()); $this->assertSame(MailTypes::TYPE_PRINT, $mail->getType()); $this->assertSame('Subject of template', $mail->getSubject()); $this->assertSame('HTML Body of template', $mail->getHtmlBody()); $this->assertSame('Body of template', $mail->getBody()); $this->assertSame($layout, $mail->getLayout()); $this->assertSame('domain', $mail->getTranslationDomain()); }
/** * Create the mail. * * @param bool $withLayout * @param bool $withTranslation * @param bool $withTranslationDomain * * @return Mail */ protected function createMail($withLayout = false, $withTranslation = false, $withTranslationDomain = false) { $mail = new Mail(); $mail->setType(MailTypes::TYPE_ALL)->setSubject('Subject of template')->setHtmlBody('HTML Body of template')->setBody('Body of template')->setName('test')->setLabel('Test')->setDescription('Description of template')->setEnabled(true)->setTranslationDomain($withTranslationDomain ? 'domain' : null); if ($withLayout) { $mail->setLayout($this->createLayout($withTranslation, $withTranslationDomain)); } if ($withTranslation && !$withTranslationDomain) { $translation = new MailTranslation($mail); $translation->setSubject('Subject of translation')->setHtmlBody('HTML body of translation')->setLocale('fr')->setLabel('Label of translation')->setDescription('Description of translation')->setBody('Body of translation'); } return $mail; }