/** * @test * it should not throw any exception if specified in config */ public function it_should_not_throw_any_exception_if_specified_in_config() { $this->config['throw'] = false; $this->executor->exec(Argument::type('string'), Argument::any(), Argument::any())->willReturn(-1); $sut = $this->make_instance(); $sut->cli('core version'); }
/** * Executes a wp-cli command. * * The method is a wrapper around isolated calls to the wp-cli tool. * The library will use its own wp-cli version to run the commands. * * @param string $userCommand The string of command and parameters as it would be passed to wp-cli * e.g. a terminal call like `wp core version` becomes `core version` * omitting the call to wp-cli script. * @return int wp-cli exit value for the command * * @throws ModuleException if the `throw` option is enabled in the config and * wp-cli return status is not 0. */ public function cli($userCommand = 'core version', &$output = []) { $this->initPaths(); $command = $this->buildCommand($userCommand); $output = []; $this->debugSection('command', $command); $status = $this->executor->exec($command, $output); $this->debugSection('output', $output); $this->evaluateStatus($output, $status); return $status == 0 ? true : $status; }