|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Paraunit\Process; |
|
6
|
|
|
|
|
7
|
|
|
use Paraunit\Configuration\PHPUnitBinFile; |
|
8
|
|
|
use Paraunit\Configuration\PHPUnitConfig; |
|
9
|
|
|
use Paraunit\Configuration\PHPUnitOption; |
|
10
|
|
|
use Paraunit\Parser\JSON\LogPrinter; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class TestCliCommand |
|
14
|
|
|
* @package Paraunit\Process |
|
15
|
|
|
*/ |
|
16
|
|
|
class CommandLine |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var PHPUnitBinFile */ |
|
19
|
|
|
protected $phpUnitBin; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* TestCliCommand constructor. |
|
23
|
|
|
* @param PHPUnitBinFile $phpUnitBin |
|
24
|
|
|
*/ |
|
25
|
47 |
|
public function __construct(PHPUnitBinFile $phpUnitBin) |
|
26
|
|
|
{ |
|
27
|
47 |
|
$this->phpUnitBin = $phpUnitBin; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return string[] |
|
32
|
|
|
*/ |
|
33
|
36 |
|
public function getExecutable(): array |
|
34
|
|
|
{ |
|
35
|
36 |
|
return ['php', $this->phpUnitBin->getPhpUnitBin()]; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param PHPUnitConfig $config |
|
40
|
|
|
* @return array |
|
41
|
|
|
* @throws \RuntimeException When the config handling fails |
|
42
|
|
|
*/ |
|
43
|
43 |
|
public function getOptions(PHPUnitConfig $config): array |
|
44
|
|
|
{ |
|
45
|
|
|
$options = [ |
|
46
|
43 |
|
'--configuration=' . $config->getFileFullPath(), |
|
47
|
|
|
'--printer=' . LogPrinter::class, |
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
43 |
|
foreach ($config->getPhpunitOptions() as $phpunitOption) { |
|
51
|
8 |
|
$options[] = $this->buildPhpunitOptionString($phpunitOption); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
43 |
|
return $options; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
8 |
|
private function buildPhpunitOptionString(PHPUnitOption $option): string |
|
58
|
|
|
{ |
|
59
|
8 |
|
$optionString = '--' . $option->getName(); |
|
60
|
8 |
|
if ($option->hasValue()) { |
|
61
|
6 |
|
$optionString .= '=' . $option->getValue(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
8 |
|
return $optionString; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param string $testFilename |
|
69
|
|
|
* @return string[] |
|
70
|
|
|
*/ |
|
71
|
25 |
|
public function getSpecificOptions(string $testFilename): array |
|
72
|
|
|
{ |
|
73
|
25 |
|
return []; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|