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