public function testEmailExtractionFromCommunicationEmail()
 {
     $email = new SimpleEmail();
     $email->addRecipientByEmail("John Smith", "*****@*****.**");
     $email->setSender("Jane Smith", "*****@*****.**");
     $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("*****@*****.**");
     $package = new CommunicationPackage();
     $package->addSendable($unitTestingEmail);
     $package->title = $unitTestingEmail->getSubject();
     $package->send();
     $item = CommunicationItem::findLast();
     $derivedEmail = $item->getSendable();
     $this->assertInstanceOf(UnitTestingTemplateEmail::class, $derivedEmail);
 }
 /**
  * @return Communication
  * @throws \Rhubarb\Stem\Exceptions\RecordNotFoundException
  */
 public function createCommunicationForEmail()
 {
     $email = new SimpleEmail();
     $email->setSubject("The three billy goats");
     $email->addRecipientByEmail("*****@*****.**", "John Smith");
     $email->setSender("*****@*****.**", "Jane Smith");
     $email->setText("Michael went to mow, went to mow a meadow.");
     $email->setHtml("<p>Michael went to mow, went to mow a meadow.</p>");
     $package = new CommunicationPackage();
     $package->addSendable($email);
     $package->title = $email->getSubject();
     $package->send();
     return Communication::findLast();
 }
 public function testCommunicationEmailProviderCantBeAProcessor()
 {
     $this->assertCount(0, CommunicationItem::find(), "CommunicationItem count was not 0");
     $this->assertCount(0, Communication::find(), "Communication count was not 0");
     $email = new SimpleEmail();
     $email->setSubject("A fine day in the park");
     $email->addRecipientByEmail("*****@*****.**", "Joe Bloggs");
     $email->setHtml("<html><head>Test Head</head><body>Test Body</body></html>");
     $email->setText("Test Text Body");
     CommunicationProcessor::setProviderClassName(EmailProvider::class, CommunicationEmailProvider::class);
     try {
         EmailProvider::setProviderClassName(CommunicationEmailProvider::class);
         EmailProvider::getProvider()->send($email);
         $this->fail('Email should not sent due to invalid Communication Provider being set');
     } catch (InvalidProviderException $exception) {
     }
 }
 private function createCommunicationWithMultipleRecipients($dateToSend, $noOfRecipients)
 {
     $email = new SimpleEmail();
     $email->setText("Test Message Body");
     $email->setSender("*****@*****.**");
     foreach (range(1, $noOfRecipients) as $i) {
         $email->addRecipientByEmail("test@test" . $i . ".com");
     }
     $package = new CommunicationPackage();
     if ($dateToSend) {
         $package->dateToSend = $dateToSend;
     }
     $package->addSendable($email);
     $package->send();
     $communication = Communication::findLast();
     return $communication;
 }
Beispiel #5
0
 private function assertReflectionMatches(Email $email)
 {
     $reflection = SimpleEmail::fromArray($email->toArray());
     $this->assertEquals($reflection, $email);
 }