/** * @test */ public function deleteAttachment() { $pathname = 'some/path/file.ext'; $filename = 'file.ext'; $attachment = new Attachment(new File($pathname)); $this->fileStorageService->expects($this->once())->method('remove')->with($this->equalTo($filename)); $this->repository->expects($this->once())->method('remove')->with($this->equalTo($attachment)); $this->manager->deleteAttachment($attachment); }
/** * @param Attachment $attachment * @return null|\Symfony\Component\HttpFoundation\File\File */ private function createThumbnail(Attachment $attachment) { $fileName = $attachment->getFile()->getPathname(); $fileParts = explode('/', $fileName); array_pop($fileParts); $prefix = array_pop($fileParts); try { $this->managerImpl->createThumbnail($attachment->getFile(), $attachment->getHash(), $prefix); $thumbnail = $this->attachmentService->getThumbnail($attachment->getHash()); } catch (\Exception $e) { $thumbnail = null; } return $thumbnail; }