Example #1
0
 public function testCreateFromFileShouldLoadContentFromFile()
 {
     $root = vfsStream::setup();
     $file = vfsStream::newFile('attachment.txt');
     $file->setContent('FOO BAR. Test content');
     $root->addChild($file);
     $attachment = Attachment::createFromFile($file->url(), 'text/plain');
     $this->assertEquals('text/plain', $attachment->getContentType());
     $this->assertEquals('attachment.txt', $attachment->getName());
     $this->assertEquals('FOO BAR. Test content', $attachment->getContent());
 }
 public function testShouldAddAttachments()
 {
     $email = new Email();
     $email->addAttachment(Email\Attachment::create()->setContent('ATTACHMENT'));
     $this->mailer->send(Argument::that(function ($argument) {
         if (!$argument instanceof \Swift_Message) {
             return false;
         }
         $children = $argument->getChildren();
         $this->assertCount(1, $children);
         $this->assertEquals('ATTACHMENT', $children[0]->getBody());
         $this->assertEquals('application/octet-stream', $children[0]->getContentType());
         return true;
     }))->willReturn(1);
     $this->handler->notify($email);
 }