コード例 #1
0
 public function it_throws_an_exception_if_the_file_can_not_be_moved($mountManager, $saver, FileInterface $file)
 {
     $file->getKey()->willReturn('path/to/file.txt');
     $mountManager->move('source://path/to/file.txt', 'destination://path/to/file.txt')->willReturn(false);
     $file->setStorage(Argument::any())->shouldNotBeCalled();
     $saver->save(Argument::any())->shouldNotBeCalled();
     $this->shouldThrow(new FileTransferException('Impossible to move the file "path/to/file.txt" from "source" to "destination".'))->during('move', [$file, 'source', 'destination']);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function move(FileInterface $file, $srcFsAlias, $destFsAlias)
 {
     $isFileMoved = $this->mountManager->move(sprintf('%s://%s', $srcFsAlias, $file->getKey()), sprintf('%s://%s', $destFsAlias, $file->getKey()));
     if (!$isFileMoved) {
         throw new FileTransferException(sprintf('Impossible to move the file "%s" from "%s" to "%s".', $file->getKey(), $srcFsAlias, $destFsAlias));
     }
     $file->setStorage($destFsAlias);
     $this->saver->save($file);
 }