private static function runCommand()

in src/TestUtils/ExecuteCommandTrait.php [30:55]


    private static function runCommand($commandName, $args = [])
    {
        if (!isset(self::$commandFile) || !file_exists(self::$commandFile)) {
            throw new \LogicException('$commandFile is not set or is missing.');
        }
        $application = require self::$commandFile;
        $command = $application->get($commandName);
        $commandTester = new CommandTester($command);

        $testFunc = function () use ($commandTester, $args) {
            ob_start();
            try {
                $commandTester->execute($args, ['interactive' => false]);
            } finally {
                // Ensure output buffer is clean even if an exception is thrown.
                $output = ob_get_clean();
            }
            return $output;
        };

        if (self::$backoff) {
            return self::$backoff->execute($testFunc);
        }

        return $testFunc();
    }