1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Tests\Unit\Command; |
6
|
|
|
|
7
|
|
|
use Paraunit\Command\ParallelCommand; |
8
|
|
|
use Paraunit\Configuration\ParallelConfiguration; |
9
|
|
|
use Paraunit\Configuration\PHPUnitConfig; |
10
|
|
|
use Paraunit\Runner\Runner; |
11
|
|
|
use Prophecy\Argument; |
12
|
|
|
use Symfony\Component\Console\Application; |
13
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
14
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
15
|
|
|
use Tests\BaseUnitTestCase; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class ParallelCommandTest |
19
|
|
|
* @package Tests\Unit\Command |
20
|
|
|
*/ |
21
|
|
|
class ParallelCommandTest extends BaseUnitTestCase |
22
|
|
|
{ |
23
|
|
|
public function testExecute() |
24
|
|
|
{ |
25
|
|
|
$phpunitConfig = $this->prophesize(PHPUnitConfig::class); |
26
|
|
|
|
27
|
|
|
$runner = $this->prophesize(Runner::class); |
28
|
|
|
$runner->run(Argument::cetera()) |
29
|
|
|
->shouldBeCalled() |
30
|
|
|
->willReturn(0); |
31
|
|
|
|
32
|
|
|
$container = $this->prophesize(ContainerBuilder::class); |
33
|
|
|
$container->get(PHPUnitConfig::class) |
34
|
|
|
->willReturn($phpunitConfig->reveal()); |
35
|
|
|
$container->get(Runner::class) |
36
|
|
|
->willReturn($runner->reveal()); |
37
|
|
|
|
38
|
|
|
$configuration = $this->prophesize(ParallelConfiguration::class); |
39
|
|
|
$configuration->buildContainer(Argument::cetera()) |
40
|
|
|
->shouldBeCalled() |
41
|
|
|
->willReturn($container->reveal()); |
42
|
|
|
|
43
|
|
|
$command = new ParallelCommand($configuration->reveal()); |
44
|
|
|
$application = new Application(); |
45
|
|
|
$application->add($command); |
46
|
|
|
$command = $application->find('run'); |
47
|
|
|
$commandTester = new CommandTester($command); |
48
|
|
|
|
49
|
|
|
$exitCode = $commandTester->execute([ |
50
|
|
|
'command' => $command->getName(), |
51
|
|
|
'stringFilter' => 'someFilter', |
52
|
|
|
'--testsuite' => 'testSuiteName', |
53
|
|
|
]); |
54
|
|
|
|
55
|
|
|
$this->assertEquals(0, $exitCode); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|