Completed
Push — master ( 70f161...72dc5f )
by Julian
10s
created

ParaTestCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 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
48 7
        if (self::isWhitelistSupported()) {
49
            $this->addOption('whitelist', null, InputOption::VALUE_REQUIRED, 'Directory to add to the coverage whitelist.');
50
        }
51 7
    }
52
53
    /**
54
     * Executes the specified tester
55
     *
56
     * @param InputInterface $input
57
     * @param OutputInterface $output
58
     * @return int|mixed|null
59
     */
60 1
    public function execute(InputInterface $input, OutputInterface $output)
61
    {
62 1
        return $this->tester->execute($input, $output);
63
    }
64
}
65