/** * Executes the command. * * @param InputInterface $input An input stream * @param OutputInterface $output An output stream * * @return int null or 0 if everything went fine, or an error code */ protected function execute(InputInterface $input, OutputInterface $output) { $dryRun = $input->getOption('dry-run'); $checkOnly = $input->getOption('check-only'); $mode = Licenser::MODE_NORMAL; if ($checkOnly) { $mode = Licenser::MODE_CHECK_ONLY; } elseif ($dryRun) { $mode = Licenser::MODE_DRY_RUN; } $logger = new ProcessLogger($output); $logger->startProcess($mode); if ($configFile = $this->extractConfigFile($input)) { foreach (ConfigFactory::createFromConfigFile($configFile, $input) as $config) { $this->buildLicenser($config, $logger)->process($mode); } } else { $config = ConfigFactory::createFromCommandLine($input); $this->buildLicenser($config, $logger)->process($mode); } $logger->finishProcess(); if ($mode === Licenser::MODE_CHECK_ONLY && $logger->countAdditions() + $logger->countUpdates() > 0) { return 1; } return 0; }
public function testCreateFromCommandLineInvalidSource() { $input = $this->buildInput(['source' => 'path']); self::setExpectedExceptionRegExp(FileNotFoundException::class); ConfigFactory::createFromCommandLine($input); }