|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Paraunit\Process; |
|
6
|
|
|
|
|
7
|
|
|
use Paraunit\Configuration\EnvVariables; |
|
8
|
|
|
use Paraunit\Configuration\PHPUnitConfig; |
|
9
|
|
|
use Paraunit\Configuration\TempFilenameFactory; |
|
10
|
|
|
use Symfony\Component\Process\ProcessBuilder; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class ProcessBuilderFactory |
|
14
|
|
|
* @package Paraunit\Process |
|
15
|
|
|
*/ |
|
16
|
|
|
class ProcessBuilderFactory implements ProcessFactoryInterface |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var ProcessBuilder */ |
|
19
|
|
|
private $builderPrototype; |
|
20
|
|
|
/** @var CommandLine */ |
|
21
|
|
|
private $cliCommand; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* ProcessBuilderFactory constructor. |
|
25
|
|
|
* @param CommandLine $cliCommand |
|
26
|
|
|
* @param PHPUnitConfig $phpunitConfig |
|
27
|
35 |
|
* @param TempFilenameFactory $tempFilenameFactory |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct( |
|
30
|
|
|
CommandLine $cliCommand, |
|
31
|
|
|
PHPUnitConfig $phpunitConfig, |
|
32
|
35 |
|
TempFilenameFactory $tempFilenameFactory |
|
33
|
35 |
|
) { |
|
34
|
|
|
$this->cliCommand = $cliCommand; |
|
35
|
35 |
|
$this->builderPrototype = new ProcessBuilder(); |
|
|
|
|
|
|
36
|
35 |
|
|
|
37
|
|
|
$this->builderPrototype->addEnvironmentVariables([ |
|
38
|
|
|
EnvVariables::LOG_DIR => $tempFilenameFactory->getPathForLog(), |
|
39
|
35 |
|
]); |
|
40
|
35 |
|
|
|
41
|
|
|
foreach ($this->cliCommand->getExecutable() as $item) { |
|
42
|
|
|
$this->builderPrototype->add($item); |
|
43
|
35 |
|
} |
|
44
|
35 |
|
|
|
45
|
|
|
foreach ($this->cliCommand->getOptions($phpunitConfig) as $option) { |
|
46
|
|
|
$this->builderPrototype->add($option); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function create(string $testFilePath): AbstractParaunitProcess |
|
51
|
|
|
{ |
|
52
|
19 |
|
$builder = clone $this->builderPrototype; |
|
53
|
|
|
$builder->add($testFilePath); |
|
54
|
19 |
|
foreach ($this->cliCommand->getSpecificOptions($testFilePath) as $specificOption) { |
|
55
|
19 |
|
$builder->add($specificOption); |
|
56
|
19 |
|
} |
|
57
|
2 |
|
|
|
58
|
|
|
return new SymfonyProcessWrapper($builder->getProcess(), $testFilePath); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.