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) {
     }
 }
Example #4
0
 public function testToArray()
 {
     $email = new SimpleEmail();
     $email->setSubject("This is a test");
     $email->setSender("*****@*****.**");
     $this->assertReflectionMatches($email);
     $email->addRecipientByEmail("*****@*****.**");
     $this->assertReflectionMatches($email);
     $email->addRecipientByEmail("*****@*****.**", "Jane Bob");
     $this->assertReflectionMatches($email);
     $email->setText("War and peace");
     $this->assertReflectionMatches($email);
     $email->setHtml("<p>War and peace</p>");
     $this->assertReflectionMatches($email);
     file_put_contents("test.txt", "abc123");
     $email->addAttachment("test.txt", "Test File.txt");
     unlink("test.txt");
     $this->assertReflectionMatches($email);
 }