Esempio n. 1
0
 /**
  * @test
  */
 public function sendCanAddOneAttachmentWithFilenameFromContent()
 {
     $content = '<p>Hello world!</p>';
     $fileName = 'greetings.html';
     $attachment = new Tx_Oelib_Attachment();
     $attachment->setContent($content);
     $attachment->setFileName($fileName);
     $attachment->setContentType('text/html');
     $sender = new Tx_Oelib_Tests_Unit_Fixtures_TestingMailRole('', '*****@*****.**');
     $recipient = new Tx_Oelib_Tests_Unit_Fixtures_TestingMailRole('John Doe', $this->email['recipient']);
     $eMail = new Tx_Oelib_Mail();
     $eMail->setSender($sender);
     $eMail->addRecipient($recipient);
     $eMail->setSubject($this->email['subject']);
     $eMail->setMessage($this->email['message']);
     $eMail->addAttachment($attachment);
     $this->subject->send($eMail);
     $children = $this->subject->getFirstSentEmail()->getChildren();
     /** @var Swift_Mime_Attachment $firstChild */
     $firstChild = $children[0];
     self::assertSame($content, $firstChild->getBody());
     self::assertSame($fileName, $firstChild->getFilename());
     self::assertSame('text/html', $firstChild->getContentType());
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function getContentWithContentSetReturnsContent()
 {
     $this->subject->setContent('test content');
     self::assertSame('test content', $this->subject->getContent());
 }
Esempio n. 3
0
 /**
  * @test
  */
 public function getAttachmentsWithTwoAttachmentsReturnsTwoAttachments()
 {
     $attachment = new Tx_Oelib_Attachment();
     $attachment->setFileName('test.txt');
     $attachment->setContentType('text/plain');
     $attachment->setContent('Test');
     $this->subject->addAttachment($attachment);
     $otherAttachment = new Tx_Oelib_Attachment();
     $otherAttachment->setFileName('second_test.txt');
     $otherAttachment->setContentType('text/plain');
     $otherAttachment->setContent('Second Test');
     $this->subject->addAttachment($otherAttachment);
     self::assertSame(array($attachment, $otherAttachment), $this->subject->getAttachments());
 }