diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..7ab80b9 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,20 @@ + + + + + + + tests/integration + + + + \ No newline at end of file diff --git a/src/Command/AnalyzeCommand.php b/src/Command/AnalyzeCommand.php index dd734be..8535bff 100644 --- a/src/Command/AnalyzeCommand.php +++ b/src/Command/AnalyzeCommand.php @@ -96,19 +96,15 @@ protected function execute(InputInterface $input, OutputInterface $output) $git = $input->getOption('git'); } - if ($files && $git) { + if (!empty($files) && $git) { throw new \Exception('Options `files` and `git` can not used in combination.'); } - if ($files) { + if (!empty($files)) { $files = explode(',', $files[0]); } - if (!$files[0]) { - $files = []; - } - - if (!$files && !$git) { + if (empty($files) && !$git) { throw new \Exception('You must set `files` or `git` options.'); } diff --git a/src/Console/Application.php b/src/Console/Application.php index 2c57be6..ea99dbf 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -23,22 +23,18 @@ class Application extends BaseApplication */ private $config; - /** - * @return \JMOlivas\Phpqa\Config - */ - public function getConfig() + public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') { - return $this->config; + parent::__construct($name, $version); + $this->config = new Config(); } /** - * {@inheritdoc} + * @return \JMOlivas\Phpqa\Config */ - public function doRun(InputInterface $input, OutputInterface $output) + public function getConfig() { - $this->config = new Config(); - - parent::doRun($input, $output); + return $this->config; } /** @@ -46,6 +42,6 @@ public function doRun(InputInterface $input, OutputInterface $output) */ public function getApplicationDirectory() { - return __DIR__.'/../../'; + return __DIR__ . '/../../'; } } diff --git a/tests/integration/Command/AnalyzeCommandTest.php b/tests/integration/Command/AnalyzeCommandTest.php new file mode 100644 index 0000000..777be17 --- /dev/null +++ b/tests/integration/Command/AnalyzeCommandTest.php @@ -0,0 +1,26 @@ +setApplication($application); + + $tester = new CommandTester($command); + + $tester->execute([]); + } +}