Exemplo n.º 1
0
 public function testCreateImageForTag()
 {
     $uploadFileDTO = $this->dummyData->getUploadFileDTO();
     $managedFile = $this->dummyData->getLocalManagedFile();
     $this->fileManager->shouldReceive('saveFile')->with($uploadFileDTO->getFilePath())->once()->andReturn($managedFile);
     $tag = $this->dummyData->getProduct();
     $this->tagRepository->shouldReceive('findOneById')->with($tag->getId())->andReturn($tag)->once();
     $this->imageRepository->shouldReceive('create')->once();
     $this->imageService->createImageForTag($uploadFileDTO, $tag->getId());
 }
Exemplo n.º 2
0
 public function createImageForTag(UploadFileDTO $uploadFileDTO, UuidInterface $tagId)
 {
     $managedFile = $this->fileManager->saveFile($uploadFileDTO->getFilePath());
     $image = new Image();
     $image->setPath($managedFile->getUri());
     $image->setWidth($managedFile->getWidth());
     $image->setHeight($managedFile->getHeight());
     $tag = $this->tagRepository->findOneById($tagId);
     $tag->addImage($image);
     $this->create($image);
 }
 public function testCreateAttachmentForOrderItem()
 {
     $order = $this->dummyData->getOrder();
     $product = $this->dummyData->getProduct();
     $product->enableAttachments();
     $orderItem = $this->dummyData->getOrderItem($order, $product);
     $uploadFileDTO = $this->dummyData->getUploadFileDTO();
     $this->orderService->shouldReceive('getOrderItemById')->with($orderItem->getId())->andReturn($orderItem)->once();
     $this->fileManager->shouldReceive('saveFile')->with($uploadFileDTO->getFilePath())->andReturn($this->dummyData->getRemoteManagedFile())->once();
     $this->attachmentRepository->shouldReceive('create')->once();
     $this->orderService->shouldReceive('update')->with($order)->once();
     $this->attachmentService->createAttachmentForOrderItem($uploadFileDTO, $orderItem->getId());
 }
Exemplo n.º 4
0
 /**
  * @param UploadFileDTO $uploadFileDTO
  * @return Attachment
  */
 private function createAttachment(UploadFileDTO $uploadFileDTO)
 {
     $managedFile = $this->fileManager->saveFile($uploadFileDTO->getFilePath());
     $attachment = new Attachment($managedFile->getUri());
     $this->attachmentRepository->create($attachment);
     return $attachment;
 }