コード例 #1
0
 function it_notify_responders_when_archive_is_not_found(ArchiveRepository $archiveRepository, UploadArchiveResponder $responder)
 {
     $archiveRepository->findByName('myArchiveName')->willReturn(null);
     $this->addResponder($responder);
     $responder->archiveNotFound('myArchiveName')->shouldBeCalled();
     $this->execute(new UploadArchiveRequest('myArchiveName', ['myProvider1']));
 }
コード例 #2
0
 function it_notify_responders_when_archive_is_created(CreateArchiveResponder $responder, ArchiveRepository $archiveRepository, Archive $archive)
 {
     $this->addResponder($responder);
     $createArchiveRequest = new CreateArchiveRequest('dummy', 'name', 'path');
     $archiveRepository->add($archive)->willReturn();
     $responder->archiveCreated('name')->shouldBeCalled();
     $responder->archiveAlreadyExists('name')->shouldNotBeCalled();
     $this->execute($createArchiveRequest);
 }
コード例 #3
0
 function it_passes_listed_archives_to_responder(ArchiveListResponder $archiveListResponder, ArchiveRepository $archiveRepository, Archive $archive, Archive $uploadedArchive)
 {
     $archive->getName()->willReturn('first');
     $archive->isUploaded()->willReturn(false);
     $uploadedArchive->getName()->willReturn('second');
     $uploadedArchive->isUploaded()->willReturn(true);
     $this->addResponder($archiveListResponder);
     $archiveRepository->findAll()->willReturn([$archive, $uploadedArchive])->shouldBeCalled();
     $archiveListResponder->archiveListFechted(Argument::that(function ($response) {
         return $response->items[0]->archiveName == 'first' && $response->items[0]->uploaded == false && $response->items[1]->archiveName == 'second' && $response->items[1]->uploaded == true;
     }))->shouldBeCalled();
     $this->execute();
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 public function execute(UploadArchiveRequest $request)
 {
     $archive = $this->archiveRepository->findByName($request->archiveName);
     if (!$archive) {
         $this->archiveNotFound($request->archiveName);
         return;
     }
     $archiveFilePaths = array_map(function (ArchiveFile $archiveFile) {
         return $archiveFile->getPath();
     }, $archive->getFiles());
     $providers = [];
     foreach ($request->providersNames as $providerName) {
         $provider = $this->uploadProviderRegistry->get($providerName);
         $provider->upload($request->archiveName, $archiveFilePaths);
         $providers[] = $provider;
     }
     $archive->upload();
     $uploadedArchive = $this->uploadedArchiveFactory->create($archive, $providers);
     $this->uploadedArchiveRepository->add($uploadedArchive);
     $this->archiveRepository->add($archive);
     $this->archiveUploaded($request->archiveName);
 }
コード例 #6
0
 public function execute()
 {
     $archives = $this->archiveRepository->findAll();
     $archivesItems = $this->fetchArchiveItems($archives);
     $this->archiveListFetched($archivesItems);
 }