1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Liip/FunctionalTestBundle |
7
|
|
|
* |
8
|
|
|
* (c) Lukas Kahwe Smith <[email protected]> |
9
|
|
|
* |
10
|
|
|
* This source file is subject to the MIT license that is bundled |
11
|
|
|
* with this source code in the file LICENSE. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Liip\FunctionalTestBundle\Command; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Console\Command\Command; |
17
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
18
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
19
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
21
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
22
|
|
|
use Symfony\Component\Process\Process; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Command used to update the project. |
26
|
|
|
*/ |
27
|
|
|
class RunParatestCommand extends Command implements ContainerAwareInterface |
28
|
|
|
{ |
29
|
|
|
use ContainerAwareTrait; |
30
|
|
|
|
31
|
|
|
private $output; |
32
|
|
|
|
33
|
|
|
private $process; |
34
|
|
|
|
35
|
|
|
private $testDbPath; |
36
|
|
|
|
37
|
|
|
private $phpunit; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Configuration of the command. |
41
|
|
|
*/ |
42
|
14 |
|
protected function configure(): void |
43
|
|
|
{ |
44
|
|
|
$this |
45
|
14 |
|
->setName('paratest:run') |
46
|
14 |
|
->setDescription('Run phpunit tests with multiple processes') |
47
|
|
|
// Pass arguments from this command "paratest:run" to the paratest command. |
48
|
14 |
|
->addArgument('options', InputArgument::OPTIONAL, 'Options') |
49
|
|
|
; |
50
|
14 |
|
} |
51
|
|
|
|
52
|
|
|
protected function prepare(): void |
53
|
|
|
{ |
54
|
|
|
$this->phpunit = $this->container->getParameter('liip_functional_test.paratest.phpunit'); |
55
|
|
|
$this->process = $this->container->getParameter('liip_functional_test.paratest.process'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Content of the command. |
60
|
|
|
* |
61
|
|
|
* @param InputInterface $input |
62
|
|
|
* @param OutputInterface $output |
63
|
|
|
* |
64
|
|
|
* @return int |
65
|
|
|
*/ |
66
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
67
|
|
|
{ |
68
|
|
|
$this->output = $output; |
69
|
|
|
$this->prepare(); |
70
|
|
|
if (true !== is_file('vendor/bin/paratest')) { |
71
|
|
|
$this->output->writeln('Error : Install paratest first'); |
72
|
|
|
|
73
|
|
|
return 1; |
74
|
|
|
} else { |
75
|
|
|
$this->output->writeln('Done...Running test.'); |
76
|
|
|
$runProcess = new Process(['vendor/bin/paratest '. |
77
|
|
|
'-c phpunit.xml.dist '. |
78
|
|
|
'--phpunit '.$this->phpunit.' '. |
79
|
|
|
'-p '.$this->process.' '. |
80
|
|
|
$input->getArgument('options'), |
81
|
|
|
]); |
82
|
|
|
$runProcess->run(function ($type, $buffer) use ($output): void { |
83
|
|
|
$output->write($buffer); |
84
|
|
|
}); |
85
|
|
|
|
86
|
|
|
return 0; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|