Beispiel #1
0
 function it_creates_backup_with_error_while_writing_resource(SourceFilesystemAdapterInterface $sourceFilesystemAdapter, TargetFilesystemAdapterInterface $targetFilesystemAdapter, NotificationInterface $notification)
 {
     $resources = [new RemoteResource('test/1.jpg'), new RemoteResource('test/2.jpg')];
     $sourceFilesystemAdapter->getResourcesList()->willReturn($resources);
     $sourceFilesystemAdapter->readStream($resources[0])->willReturn('resource');
     $sourceFilesystemAdapter->readStream($resources[1])->willReturn('resource');
     $targetFilesystemAdapter->writeStream($resources[0], 'resource')->willReturn('resource');
     $targetFilesystemAdapter->writeStream($resources[1], 'resource')->willReturn(false);
     $this->run($notification);
     $notification->notifyErrorWritingResources($resources[1])->shouldBeCalledTimes(1);
     $notification->notifySuccessStepProcess($resources[0])->shouldBeCalledTimes(1);
     $notification->runProcess(count($resources))->shouldBeCalled();
     $notification->finishProcess()->shouldBeCalled();
 }
Beispiel #2
0
 private function backupResource(RemoteResource $remoteResource, NotificationInterface $notification)
 {
     if ($remoteResource->getType() === RemoteResource::TYPE_DIRECTORY) {
         return $this->targetFilesystemAdapter->createDirectory($remoteResource);
     }
     $fileStream = $this->sourceFilesystemAdapter->readStream($remoteResource);
     if ($fileStream === false) {
         $notification->notifyErrorReadingResources($remoteResource);
         return false;
     }
     $writeResult = $this->targetFilesystemAdapter->writeStream($remoteResource, $fileStream);
     if ($writeResult === false) {
         $notification->notifyErrorWritingResources($remoteResource);
         return false;
     }
     return true;
 }