public function get($remote, $local)
{
if (!$this->node) {
throw new \RuntimeException("Node is not defined to get a file.");
}
$this->runtimeTask->getOutput()->writeln($this->getRemoteInfoPrefix() . "<info>Get: </info>{$remote} -> {$local}");
$sftp = $this->getSFTP();
if (!is_dir(dirname($local))) {
$fs = new Filesystem();
$fs->mkdir(dirname($local));
if ($this->runtimeTask->getOutput()->isVerbose()) {
$this->runtimeTask->getOutput()->writeln($this->getRemoteInfoPrefix() . "<info>Create directory: </info>" . dirname($local));
}
}
$ret = $sftp->get($remote, $local);
if ($ret === false) {
throw new \RuntimeException("Couldn't get: {$remote} -> {$local}");
}
return $ret;
}
public function testGet2() { $srcPath = "/NotExistsFile/gettest.txt"; $destPath = __DIR__ . "/../../../../tmp/Altax/Module/Task/Process/ProcessTest/gettest.txt"; $this->runtimeTask->getOutput()->setVerbosity(3); $node = new Node(); $node->setName("127.0.0.1"); $process = new Process($this->runtimeTask, $node); try { $process->get($srcPath, $destPath); $this->assertEquals(false, true); } catch (\RuntimeException $e) { $this->assertEquals(true, true); } }