1
|
|
|
<?php |
2
|
|
|
namespace ParaTest\Console\Testers; |
3
|
|
|
|
4
|
|
|
use Symfony\Component\Console\Command\Command; |
5
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
6
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Tester |
11
|
|
|
* |
12
|
|
|
* A base for Testers. A Tester is a specialized console |
13
|
|
|
* command for controlling a given tool - i.e PHPUnit |
14
|
|
|
* |
15
|
|
|
* @package ParaTest\Console\Testers |
16
|
|
|
*/ |
17
|
|
|
abstract class Tester |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Configures the ParaTestCommand with Tester specific |
21
|
|
|
* definitions |
22
|
|
|
* |
23
|
|
|
* @param Command $command |
24
|
|
|
* @return mixed |
25
|
|
|
*/ |
26
|
|
|
abstract public function configure(Command $command); |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param InputInterface $input |
30
|
|
|
* @param OutputInterface $output |
31
|
|
|
* @return mixed |
32
|
|
|
*/ |
33
|
|
|
abstract public function execute(InputInterface $input, OutputInterface $output); |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Returns non-empty options |
37
|
|
|
* |
38
|
|
|
* @param InputInterface $input |
39
|
|
|
* @return array |
40
|
|
|
*/ |
41
|
4 |
|
protected function getOptions(InputInterface $input) |
42
|
|
|
{ |
43
|
4 |
|
$options = $input->getOptions(); |
44
|
4 |
|
foreach ($options as $key => $value) { |
45
|
4 |
|
if (empty($options[$key])) { |
46
|
4 |
|
unset($options[$key]); |
47
|
4 |
|
} |
48
|
4 |
|
} |
49
|
4 |
|
return $options; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Displays help for the ParaTestCommand |
54
|
|
|
* |
55
|
|
|
* @param InputInterface $input |
56
|
|
|
* @param OutputInterface $output |
57
|
|
|
*/ |
58
|
|
|
protected function displayHelp(InputInterface $input, OutputInterface $output) |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
$help = $this->command->getApplication()->find('help'); |
|
|
|
|
61
|
|
|
$input = new ArrayInput(array('command_name' => 'paratest')); |
62
|
|
|
$help->run($input, $output); |
63
|
|
|
exit(0); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.