/** * @param $entity * * @return array */ public function getScopeEntityAttachments($entity) { $attachments = []; $oroAttachments = $this->attachmentProvider->getEntityAttachments($entity); foreach ($oroAttachments as $oroAttachment) { $attachments[] = $this->emailAttachmentTransformer->oroToModel($oroAttachment); } return $attachments; }
public function testOroToModel() { $attachmentOro = $this->getMock('Oro\\Bundle\\AttachmentBundle\\Entity\\Attachment'); $attachmentOro->expects($this->once())->method('getId')->willReturn(1); $file = $this->getMock('Oro\\Bundle\\AttachmentBundle\\Entity\\File'); $file->expects($this->once())->method('getOriginalFilename')->willReturn('filename.txt'); $file->expects($this->once())->method('getFileSize')->willReturn(100); $attachmentOro->expects($this->exactly(2))->method('getFile')->willReturn($file); $attachmentOro->expects($this->once())->method('getCreatedAt')->willReturn('2015-04-13 19:09:32'); $attachmentModel = $this->emailAttachmentTransformer->oroToModel($attachmentOro); $this->assertInstanceOf('Oro\\Bundle\\EmailBundle\\Form\\Model\\EmailAttachment', $attachmentModel); $this->assertEquals(1, $attachmentModel->getId()); $this->assertEquals(100, $attachmentModel->getFileSize()); $this->assertEquals('2015-04-13 19:09:32', $attachmentModel->getModified()); $this->assertEquals(1, $attachmentModel->getType()); $this->assertEquals(null, $attachmentModel->getEmailAttachment()); }