|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Paraunit\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Paraunit\Configuration\ParallelCoverageConfiguration; |
|
6
|
|
|
use Paraunit\Configuration\PhpCodeCoverageCompat; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class CoverageCommand |
|
13
|
|
|
* @package Paraunit\Command |
|
14
|
|
|
*/ |
|
15
|
|
|
class CoverageCommand extends ParallelCommand |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* ParallelCommand constructor. |
|
19
|
|
|
* @param ParallelCoverageConfiguration $configuration |
|
20
|
|
|
*/ |
|
21
|
3 |
|
public function __construct(ParallelCoverageConfiguration $configuration) |
|
22
|
|
|
{ |
|
23
|
3 |
|
parent::__construct($configuration); |
|
24
|
3 |
|
} |
|
25
|
|
|
|
|
26
|
3 |
|
protected function configure() |
|
27
|
|
|
{ |
|
28
|
3 |
|
parent::configure(); |
|
29
|
|
|
|
|
30
|
3 |
|
$this |
|
31
|
3 |
|
->setName('coverage') |
|
32
|
3 |
|
->addOption('clover', null, InputOption::VALUE_REQUIRED, 'Output file for Clover XML coverage result') |
|
33
|
3 |
|
->addOption('xml', null, InputOption::VALUE_REQUIRED, 'Output dir for PHPUnit XML coverage result') |
|
34
|
3 |
|
->addOption('html', null, InputOption::VALUE_REQUIRED, 'Output dir for HTML coverage result'); |
|
35
|
3 |
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param InputInterface $input |
|
39
|
|
|
* @param OutputInterface $output |
|
40
|
|
|
* |
|
41
|
|
|
* @return int|null |
|
42
|
|
|
* |
|
43
|
|
|
* @throws \Exception |
|
44
|
|
|
*/ |
|
45
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
46
|
|
|
{ |
|
47
|
2 |
|
if (! $this->hasChosenCoverageMethod($input)) { |
|
48
|
1 |
|
throw new \InvalidArgumentException('You should choose at least one method of coverage output, between Clover, XML or HTML'); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
1 |
|
PhpCodeCoverageCompat::load(); |
|
52
|
|
|
|
|
53
|
1 |
|
return parent::execute($input, $output); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param InputInterface $input |
|
58
|
|
|
* @return bool |
|
59
|
|
|
*/ |
|
60
|
2 |
|
private function hasChosenCoverageMethod(InputInterface $input) |
|
61
|
|
|
{ |
|
62
|
2 |
|
return $input->getOption('clover') |
|
63
|
2 |
|
|| $input->getOption('html') |
|
64
|
2 |
|
|| $input->getOption('xml'); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|