/** * @test */ public function runLocalCommandasUser() { try { $testfile = tempnam(sys_get_temp_dir(), __FUNCTION__); $command = new Command(new LocalConnection(), 'whoami > ' . $testfile, 'root'); $command->exec(); $this->assertEquals('root', trim(file_get_contents($testfile))); unlink($testfile); } catch (\Exception $e) { $this->markTestSkipped('It is ok if this test fails'); } }
/** * Execute command on this connection * * @param string $command * @return array */ public function exec($command) { $command = new Command($this, $command); return $command->exec(); }
/** * Execute command on this connection * * @param string $command * @param string $asUser * @return array */ public function exec($command, $asUser = null) { $command = new Command($this, $command, $asUser); return $command->exec(); }