Completed
Pull Request — master (#217)
by
unknown
03:02
created

ParaTestCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 92%

Importance

Changes 4
Bugs 2 Features 1
Metric Value
wmc 5
c 4
b 2
f 1
lcom 1
cbo 4
dl 0
loc 57
ccs 23
cts 25
cp 0.92
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isWhitelistSupported() 0 4 1
A __construct() 0 6 1
A configure() 0 19 2
A execute() 0 4 1
1
<?php namespace ParaTest\Console\Commands;
2
3
use Composer\Semver\Comparator;
4
use Symfony\Component\Console\Command\Command;
5
use Symfony\Component\Console\Input\InputOption;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use ParaTest\Console\Testers\Tester;
9
10
class ParaTestCommand extends Command
11
{
12
    /**
13
     * @var \ParaTest\Console\Testers\Tester
14
     */
15
    protected $tester;
16
17 7
    public function __construct(Tester $tester)
18
    {
19 7
        parent::__construct('paratest');
20 7
        $this->tester = $tester;
21 7
        $this->tester->configure($this);
22 7
    }
23
24
    /**
25
     * @return bool
26
     */
27 9
    public static function isWhitelistSupported()
28
    {
29 9
        return Comparator::greaterThanOrEqualTo(\PHPUnit_Runner_Version::id(), '5.0.0');
30
    }
31
32
    /**
33
     * Ubiquitous configuration options for ParaTest
34
     */
35 7
    protected function configure()
36
    {
37 7
        $this
38 7
            ->addOption('processes', 'p', InputOption::VALUE_REQUIRED, 'The number of test processes to run.', 5)
39 7
            ->addOption('functional', 'f', InputOption::VALUE_NONE, 'Run methods instead of suites in separate processes.')
40 7
            ->addOption('no-test-tokens', null, InputOption::VALUE_NONE, 'Disable TEST_TOKEN environment variables. <comment>(default: variable is set)</comment>')
41 7
            ->addOption('help', 'h', InputOption::VALUE_NONE, 'Display this help message.')
42 7
            ->addOption('coverage-clover', null, InputOption::VALUE_REQUIRED, 'Generate code coverage report in Clover XML format.')
43 7
            ->addOption('coverage-html', null, InputOption::VALUE_REQUIRED, 'Generate code coverage report in HTML format.')
44 7
            ->addOption('coverage-php', null, InputOption::VALUE_REQUIRED, 'Serialize PHP_CodeCoverage object to file.')
45 7
            ->addOption('max-batch-size', 'm', InputOption::VALUE_REQUIRED, 'Max batch size (only for functional mode).', 0)
46 7
            ->addOption('filter', null, InputOption::VALUE_REQUIRED, 'Filter (only for functional mode).')
47 7
            ->addOption('repeat', null, InputOption::VALUE_REQUIRED, 'Runs the test(s) repeatedly.', 1);
48
49
50 7
        if (self::isWhitelistSupported()) {
51
            $this->addOption('whitelist', null, InputOption::VALUE_REQUIRED, 'Directory to add to the coverage whitelist.');
52
        }
53 7
    }
54
55
    /**
56
     * Executes the specified tester
57
     *
58
     * @param InputInterface $input
59
     * @param OutputInterface $output
60
     * @return int|mixed|null
61
     */
62 1
    public function execute(InputInterface $input, OutputInterface $output)
63
    {
64 1
        return $this->tester->execute($input, $output);
65
    }
66
}
67