|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Paraunit\Process; |
|
4
|
|
|
|
|
5
|
|
|
use Paraunit\Configuration\PHPUnitBinFile; |
|
6
|
|
|
use Paraunit\Configuration\PHPUnitConfig; |
|
7
|
|
|
use Paraunit\Configuration\TempFilenameFactory; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class TestCliCommand |
|
11
|
|
|
* @package Paraunit\Process |
|
12
|
|
|
*/ |
|
13
|
|
|
class TestCommandLine implements CliCommandInterface |
|
14
|
|
|
{ |
|
15
|
|
|
/** @var PHPUnitBinFile */ |
|
16
|
|
|
private $phpUnitBin; |
|
17
|
|
|
|
|
18
|
|
|
/** @var TempFilenameFactory */ |
|
19
|
|
|
protected $filenameFactory; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* TestCliCommand constructor. |
|
23
|
|
|
* @param PHPUnitBinFile $phpUnitBin |
|
24
|
|
|
* @param TempFilenameFactory $filenameFactory |
|
25
|
|
|
*/ |
|
26
|
16 |
|
public function __construct(PHPUnitBinFile $phpUnitBin, TempFilenameFactory $filenameFactory) |
|
27
|
|
|
{ |
|
28
|
16 |
|
$this->phpUnitBin = $phpUnitBin; |
|
29
|
16 |
|
$this->filenameFactory = $filenameFactory; |
|
30
|
16 |
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return string |
|
34
|
|
|
*/ |
|
35
|
13 |
|
public function getExecutable() |
|
36
|
|
|
{ |
|
37
|
13 |
|
return $this->phpUnitBin->getPhpUnitBin(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param PHPUnitConfig $config |
|
42
|
|
|
* @param string $uniqueId |
|
43
|
|
|
* @return string |
|
44
|
|
|
*/ |
|
45
|
13 |
|
public function getOptions(PHPUnitConfig $config, $uniqueId) |
|
46
|
|
|
{ |
|
47
|
13 |
|
return '-c ' . $config->getFileFullPath() |
|
48
|
13 |
|
. ' --log-json ' . $this->filenameFactory->getFilenameForLog($uniqueId) |
|
49
|
13 |
|
. $this->createOptionsString($config); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
13 |
|
private function createOptionsString(PHPUnitConfig $config) |
|
53
|
|
|
{ |
|
54
|
13 |
|
$optionString = ''; |
|
55
|
|
|
|
|
56
|
13 |
|
foreach ($config->getPhpunitOptions() as $option) { |
|
57
|
3 |
|
$optionString .= ' --' . $option->getName(); |
|
58
|
3 |
|
if ($option->hasValue()) { |
|
59
|
3 |
|
$optionString .= '=' . $option->getValue(); |
|
60
|
3 |
|
} |
|
61
|
13 |
|
} |
|
62
|
|
|
|
|
63
|
13 |
|
return $optionString; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|