Inheritance: extends Symfony\Component\Console\Helper\Helper, implements Platformsh\Cli\Helper\ShellHelperInterface
 /**
  * Test ShellHelper::execute().
  */
 public function testExecute()
 {
     $shellHelper = new ShellHelper();
     // Find a command that will work on all platforms.
     $workingCommand = strpos(PHP_OS, 'WIN') !== false ? 'help' : 'pwd';
     // With $mustRun disabled.
     $this->assertNotEmpty($shellHelper->execute(array($workingCommand)));
     $this->assertFalse($shellHelper->execute(array('which', 'nonexistent')));
     // With $mustRun enabled.
     $this->assertNotEmpty($shellHelper->execute(array($workingCommand), null, true));
     $this->setExpectedException('Exception');
     $shellHelper->execute(array('which', 'nonexistent'), null, true);
 }
Example #2
0
 /**
  * Run a user-defined hook.
  *
  * @param string|array $hook
  * @param string       $dir
  *
  * @return bool
  */
 protected function runHook($hook, $dir)
 {
     $code = $this->shellHelper->executeSimple(implode("\n", (array) $hook), $dir);
     if ($code !== 0) {
         $this->output->writeln("<comment>The hook failed with the exit code: {$code}</comment>");
         return false;
     }
     return true;
 }