function let(FileSourceRegistry $fileSourceRegistry, ArchiveFactory $archiveFactory, ArchiveRepository $archiveRepository, FileSource $fileSource, Archive $archive, Archive $existingArchive, ArchiveRepository $archiveRepository, File $file)
 {
     $fileSourceRegistry->get('dummy')->willReturn($fileSource);
     $fileSource->getFiles('path')->willReturn([$file]);
     $archiveFactory->create('name', Argument::that(function ($archiveFiles) {
         foreach ($archiveFiles as $archiveFile) {
             if (!$archiveFile instanceof ArchiveFile) {
                 return false;
             }
         }
         return true;
     }))->willReturn($archive);
     $archiveFactory->create('existingName', Argument::that(function ($archiveFiles) {
         foreach ($archiveFiles as $archiveFile) {
             if (!$archiveFile instanceof ArchiveFile) {
                 return false;
             }
         }
         return true;
     }))->willReturn($existingArchive);
     $archive->getName()->willReturn('name');
     $existingArchive->getName()->willReturn('existingName');
     $archiveRepository->findByName("name")->willReturn(null);
     $archiveRepository->findByName("existingName")->willReturn($existingArchive);
     $this->beConstructedWith($fileSourceRegistry, $archiveFactory, $archiveRepository);
 }
 public function execute(CreateArchiveRequest $request)
 {
     $fileSource = $this->fileSourceRegistry->get($request->fileSource);
     $files = $fileSource->getFiles($request->path);
     $archiveFiles = [];
     foreach ($files as $file) {
         $archiveFiles[] = new ArchiveFile($file->path);
     }
     $archive = $this->archiveFactory->create($request->archiveName, $archiveFiles);
     if ($this->archiveRepository->findByName($request->archiveName)) {
         $this->archiveAlreadyExists($archive);
         return;
     }
     $this->archiveRepository->add($archive);
     $this->archiveCreated($archive);
 }