示例#1
0
 public function testWhenCopyFailsItRaisesAnException()
 {
     $fileSystem = $this->getFilesystem();
     $localFile = new FileNode($fileSystem, 'some/random');
     $newPath = new FileNode($fileSystem, 'some/target');
     $fileSystem->shouldReceive('copy')->with($localFile->getPath(), $newPath->getPath())->andReturn(false);
     $this->expectException(CopyFailedException::class);
     $localFile->copy($newPath->getPath());
 }
示例#2
0
 /**
  * @param NodeInterface $node
  *
  * @return FileNode
  */
 public function flow(NodeInterface $node)
 {
     if (!$node instanceof FileNode) {
         throw new InvalidArgumentException("Node: {$node} should be an instance of FileNode");
     }
     if (substr($this->target->getPath(), -1) == '/') {
         $target = $this->target->getClone()->setPath($this->target->getPath() . $node->getFilename());
     } else {
         $target = $this->target;
     }
     return $this->moveTo($node, $target);
 }
示例#3
0
 /**
  * @param FileNode $from
  * @param FileNode $to
  *
  * @return FileNode
  * @throws TransferFailedException
  */
 public function moveTo(FileNode $from, FileNode $to)
 {
     $mountManager = new MountManager(['from' => $from->getFilesystem(), 'to' => $to->getFilesystem()]);
     $this->log(LogLevel::INFO, "Moving file from: '{from}', to: '{to}'", ['from' => $from, 'to' => $to]);
     if (!$mountManager->move('from://' . $from->getPath(), 'to://' . $to->getPath())) {
         throw new TransferFailedException($from, $to);
     }
     return $to;
 }
示例#4
0
 public function testMoveWhenFilesystemDoesNotReadStreamThrowsAnException()
 {
     $filesystem = m::mock(FilesystemInterface::class)->makePartial();
     $fromFile = new FileNode($filesystem, 'some/file');
     $toFile = new LocalFile(static::$dir . 'fail_move_file.text');
     $filesystem->shouldReceive('readStream')->with($fromFile->getPath())->andReturn(false);
     $this->expectException(TransferFailedException::class);
     $this->transfer->moveTo($fromFile, $toFile);
 }