ProcessHelper example

return [new HelpCommand()new ListCommand()new CompleteCommand()new DumpCompletionCommand()];
    }

    /** * Gets the default helper set with the helpers that should always be available. */
    protected function getDefaultHelperSet(): HelperSet
    {
        return new HelperSet([
            new FormatterHelper(),
            new DebugFormatterHelper(),
            new ProcessHelper(),
            new QuestionHelper(),
        ]);
    }

    /** * Returns abbreviated suggestions in string format. */
    private function getAbbreviationSuggestions(array $abbrevs): string
    {
        return ' '.implode("\n ", $abbrevs);
    }

    
return [new HelpCommand()new ListCommand()new CompleteCommand()new DumpCompletionCommand()];
    }

    /** * Gets the default helper set with the helpers that should always be available. */
    protected function getDefaultHelperSet(): HelperSet
    {
        return new HelperSet([
            new FormatterHelper(),
            new DebugFormatterHelper(),
            new ProcessHelper(),
            new QuestionHelper(),
        ]);
    }

    /** * Returns abbreviated suggestions in string format. */
    private function getAbbreviationSuggestions(array $abbrevs): string
    {
        return ' '.implode("\n ", $abbrevs);
    }

    
class ProcessHelperTest extends TestCase
{
    /** * @dataProvider provideCommandsAndOutput */
    public function testVariousProcessRuns(string $expected, Process|string|array $cmd, int $verbosity, ?string $error)
    {
        if (\is_string($cmd)) {
            $cmd = Process::fromShellCommandline($cmd);
        }

        $helper = new ProcessHelper();
        $helper->setHelperSet(new HelperSet([new DebugFormatterHelper()]));
        $output = $this->getOutputStream($verbosity);
        $helper->run($output$cmd$error);
        $this->assertEquals($expected$this->getOutput($output));
    }

    public function testPassedCallbackIsExecuted()
    {
        $helper = new ProcessHelper();
        $helper->setHelperSet(new HelperSet([new DebugFormatterHelper()]));
        $output = $this->getOutputStream(StreamOutput::VERBOSITY_NORMAL);

        
Home | Imprint | This part of the site doesn't use cookies.