public function putString($remote, $contents)
{
if (!$this->node) {
throw new \RuntimeException("Node is not defined to put a file.");
}
$this->runtimeTask->getOutput()->writeln($this->getRemoteInfoPrefix() . "<info>Put: </info>{$remote}");
$sftp = $this->getSFTP();
$ret = $sftp->put($remote, $contents);
if ($ret === false) {
throw new \RuntimeException("Couldn't put: {$remote}");
}
return $ret;
}
public function testPutString2() { $srcPath = "/NotExistsFile/gettest.txt"; $this->runtimeTask->getOutput()->setVerbosity(3); $node = new Node(); $node->setName("127.0.0.1"); $process = new Process($this->runtimeTask, $node); try { $process->putString($srcPath, "putstring contents"); $this->assertEquals(false, true); } catch (\RuntimeException $e) { $this->assertEquals(true, true); } }