コード例 #1
0
 public function testEmailExtractionFromCommunicationEmail()
 {
     $email = new SimpleEmail();
     $email->addRecipientByEmail("John Smith", "john.smith@outlook.com");
     $email->setSender("Jane Smith", "jane.smith@outlook.com");
     $email->setSubject("The three billy goats");
     $email->setText("Michael went to mow, went to mow a meadow.");
     $email->setHtml("<p>Michael went to mow, went to mow a meadow.</p>");
     $email->addAttachment("file_location.txt");
     $email->addAttachment("file_location1.txt", "TestFakeFileName");
     $package = new CommunicationPackage();
     $package->addSendable($email);
     $package->title = $email->getSubject();
     $package->send();
     $item = CommunicationItem::findLast();
     $derivedEmail = $item->getSendable();
     $this->assertEquals($email, $derivedEmail, "The derived email isn't exactly the same as the original");
     $this->assertInstanceOf(SimpleEmail::class, $derivedEmail);
     // Next test is that a different sendable generates the correct type when getSendable is called.
     $unitTestingEmail = new UnitTestingTemplateEmail(['Name' => "", 'Age' => "", 'HairColour' => ""]);
     $unitTestingEmail->addRecipientByEmail("billybob@gmail.com");
     $package = new CommunicationPackage();
     $package->addSendable($unitTestingEmail);
     $package->title = $unitTestingEmail->getSubject();
     $package->send();
     $item = CommunicationItem::findLast();
     $derivedEmail = $item->getSendable();
     $this->assertInstanceOf(UnitTestingTemplateEmail::class, $derivedEmail);
 }
コード例 #2
0
 public function testTemplateEmailWorks()
 {
     $email = new UnitTestingTemplateEmail(["Name" => "Fairbanks", "Age" => "21++", "HairColour" => "brown"]);
     $this->assertEquals("Your name is Fairbanks", $email->getText());
     $this->assertEquals("Your age is 21++", $email->getHtml());
     $this->assertEquals("Your hair is brown", $email->getSubject());
     $email = new FancyUnitTestingTemplateEmail(["Name" => "Fairbanks", "Age" => "21++", "HairColour" => "brown"]);
     $this->assertEquals("<div>Your age is 21++</div>", $email->getHtml(), "Templated emails using layouts aren't using the html layout");
     $this->assertEquals("abcYour name is Fairbanksdef", $email->getText(), "Templated emails using layouts aren't using the text layout");
 }