public function exec() { // file_put_contents('/tmp/exec.log', $this->__toString() . "\n\n", FILE_APPEND); $returnVar = null; exec($this->__toString(), $output, $returnVar); return ['output' => $output, 'returnVar' => $returnVar]; }
/** * @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'); } }