/** * @test */ public function canCommandConstructCommands() { // simple test with no arguments. $command = new Command('pwd'); $this->assertEquals('pwd;', $command->getCommand(), 'Basic command constructed incorrectly'); // same thing with arguments. $command = new Command('wget', ['http://google.com', 'google.html']); $this->assertEquals('wget http://google.com google.html;', $command->getCommand(), 'Command with arguments constructed incorrectly'); // make sure the command can clean up a messy command. $command = new Command(' cd /home/root ;'); $this->assertEquals('cd /home/root;', $command->getCommand(), 'Command was not cleaned up as expected'); }
/** * Return the final compiled script that will be executed on the server. * * @return string */ public function getExecutableScript() { $batches = []; $break = new Command(sprintf('echo "%s";', static::BATCH_BREAK)); foreach ($this->batches as $batch) { $batches[] = $break->getCommand(); $batches[] = $batch->getCompiled(); } $batches[] = $break->getCommand(); $script = implode(' ', $batches); return $this->authentication->wrap($script); }