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()); }
/** * @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; }
public function testFindOneByIdThrowsException() { $this->setExpectedException(EntityNotFoundException::class, 'Attachment not found'); $this->attachmentRepository->findOneById($this->dummyData->getId()); }