コード例 #1
0
 /**
  * Ensures everything works as expected
  */
 public function testOk()
 {
     $message = new ImapMessageEntity();
     foreach ($this->input as $field => $value) {
         if ($field == 'attachments') {
             for ($i = 0, $len = count($value); $i < $len; $i++) {
                 $attData =& $value[$i];
                 $attachment = new \Conjoon\Data\Entity\Mail\DefaultAttachmentEntity();
                 $attachment->setKey($attData['key']);
                 $attachment->setFileName($attData['fileName']);
                 $attachment->setMimeType($attData['mimeType']);
                 $attachment->setEncoding($attData['encoding']);
                 $attachment->setContentId($attData['contentId']);
                 $mailAttachmentContent = new \Conjoon\Data\Entity\Mail\DefaultAttachmentContentEntity();
                 $mailAttachmentContent->setContent($attData['mailAttachmentContent']['content']);
                 $attachment->setAttachmentContent($mailAttachmentContent);
                 $message->addAttachment($attachment);
             }
             $this->assertSame(2, count($message->getAttachments()));
             for ($i = 0, $len = 2; $i < 2; $i++) {
                 $attachment = $message->getAttachments();
                 $attachment = $attachment[$i];
                 $attData =& $value[$i];
                 $this->assertSame($attData['key'], $attachment->getKey());
                 $this->assertSame($attData['fileName'], $attachment->getFileName());
                 $this->assertSame($attData['mimeType'], $attachment->getMimeType());
                 $this->assertSame($attData['encoding'], $attachment->getEncoding());
                 $this->assertSame($attData['contentId'], $attachment->getContentId());
                 $mailAttachmentContent = $attachment->getAttachmentContent();
                 $this->assertSame($attData['mailAttachmentContent']['content'], $mailAttachmentContent->getContent());
             }
             continue;
         }
         $methodSet = "set" . ucfirst($field);
         $methodGet = "get" . ucfirst($field);
         $message->{$methodSet}($value);
         $this->assertSame($value, $message->{$methodGet}());
     }
 }
コード例 #2
0
 /**
  * @inheritdoc
  */
 public function createFrom(array $options)
 {
     $stringEmptyCheck = array('type' => 'string', 'allowEmpty' => true);
     $stringCheck = array('type' => 'string', 'allowEmpty' => false);
     try {
         ArgumentCheck::check(array('mimeType' => $stringEmptyCheck, 'encoding' => $stringEmptyCheck, 'fileName' => $stringCheck, 'content' => $stringEmptyCheck, 'contentId' => $stringEmptyCheck), $options);
         $attachmentEntity = new \Conjoon\Data\Entity\Mail\DefaultAttachmentEntity();
         $attachmentContent = new \Conjoon\Data\Entity\Mail\DefaultAttachmentContentEntity();
         $attachmentEntity->setMimeType($options['mimeType']);
         $attachmentEntity->setEncoding($options['encoding']);
         $attachmentEntity->setFileName($options['fileName']);
         $attachmentEntity->setContentId($options['contentId']);
         $attachmentEntity->setKey(md5($options['content']));
         $attachmentContent->setContent($options['content']);
         $attachmentEntity->setAttachmentContent($attachmentContent);
         return $attachmentEntity;
     } catch (\Exception $e) {
         throw new MailEntityCreatorException("Excpetion thrown by previous exception: " . $e->getMessage(), 0, $e);
     }
 }
コード例 #3
0
 /**
  * Ensures everything works as expected.
  */
 public function testPersistCreateUsingMessageByFind()
 {
     $messageRepository = $this->_entityManager->getRepository('\\Conjoon\\Data\\Entity\\Mail\\DefaultMessageEntity');
     $repository = $this->_entityManager->getRepository('\\Conjoon\\Data\\Entity\\Mail\\DefaultAttachmentEntity');
     $message = $messageRepository->findById(1);
     $attachment = new \Conjoon\Data\Entity\Mail\DefaultAttachmentEntity();
     $attachmentContent = new \Conjoon\Data\Entity\Mail\DefaultAttachmentContentEntity();
     $attachmentContent->setContent('BLOB3');
     $attachment->setKey('key3');
     $attachment->setMimeType('mimetype');
     $attachment->setFileName('filename');
     $attachment->setEncoding('encoding');
     $attachment->setContentId('contentid');
     $attachment->setAttachmentContent($attachmentContent);
     $message->addAttachment($attachment);
     $messageRepository->register($message);
     $this->assertEquals(2, $this->getConnection()->getRowCount('groupware_email_items_attachments'), "Pre-Condition");
     $messageRepository->flush();
     $this->assertEquals(3, $this->getConnection()->getRowCount('groupware_email_items_attachments'), "Pre-Condition");
     $queryTable = $this->getConnection()->createQueryTable('groupware_email_items_attachments', 'SELECT * FROM groupware_email_items_attachments');
     $expectedTable = $this->createXmlDataSet(dirname(__FILE__) . '/fixtures/mysql/attachment.addbyfind.result.xml')->getTable("groupware_email_items_attachments");
     $this->assertTablesEqual($expectedTable, $queryTable);
     $queryTable = $this->getConnection()->createQueryTable('mail_attachment_content', 'SELECT * FROM mail_attachment_content');
     $expectedTable = $this->createXmlDataSet(dirname(__FILE__) . '/fixtures/mysql/attachment.add.result.xml')->getTable("mail_attachment_content");
     $this->assertTablesEqual($expectedTable, $queryTable);
 }