|
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\Process; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class ProcessFactory |
|
14
|
|
|
* @package Paraunit\Process |
|
15
|
|
|
*/ |
|
16
|
|
|
class ProcessFactory implements ProcessFactoryInterface |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var CommandLine */ |
|
19
|
|
|
private $cliCommand; |
|
20
|
|
|
|
|
21
|
|
|
/** @var string[] */ |
|
22
|
|
|
private $baseCommandLine; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string[] */ |
|
25
|
|
|
private $environmentVariables; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* ProcessFactory constructor. |
|
29
|
|
|
* @param CommandLine $cliCommand |
|
30
|
|
|
* @param PHPUnitConfig $phpunitConfig |
|
31
|
|
|
* @param TempFilenameFactory $tempFilenameFactory |
|
32
|
|
|
*/ |
|
33
|
41 |
|
public function __construct( |
|
34
|
|
|
CommandLine $cliCommand, |
|
35
|
|
|
PHPUnitConfig $phpunitConfig, |
|
36
|
|
|
TempFilenameFactory $tempFilenameFactory |
|
37
|
|
|
) { |
|
38
|
41 |
|
$this->cliCommand = $cliCommand; |
|
39
|
41 |
|
$this->baseCommandLine = array_merge($this->cliCommand->getExecutable(), $this->cliCommand->getOptions($phpunitConfig)); |
|
|
|
|
|
|
40
|
41 |
|
$this->environmentVariables = [ |
|
|
|
|
|
|
41
|
41 |
|
EnvVariables::LOG_DIR => $tempFilenameFactory->getPathForLog(), |
|
42
|
|
|
]; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
25 |
|
public function create(string $testFilePath): AbstractParaunitProcess |
|
46
|
|
|
{ |
|
47
|
25 |
|
$process = new Process( |
|
48
|
25 |
|
array_merge($this->baseCommandLine, [$testFilePath], $this->cliCommand->getSpecificOptions($testFilePath)), |
|
49
|
25 |
|
null, |
|
50
|
25 |
|
$this->environmentVariables |
|
51
|
|
|
); |
|
52
|
|
|
|
|
53
|
25 |
|
if (method_exists($process, 'inheritEnvironmentVariables')) { |
|
54
|
|
|
// method added in 3.0 |
|
55
|
25 |
|
$process->inheritEnvironmentVariables(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
25 |
|
return new SymfonyProcessWrapper($process, $testFilePath); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..