|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Paraunit\Configuration; |
|
5
|
|
|
|
|
6
|
|
|
use Symfony\Component\Config\FileLocator; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
10
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
12
|
|
|
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; |
|
13
|
|
|
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class Paraunit |
|
17
|
|
|
* @package Paraunit\Configuration |
|
18
|
|
|
*/ |
|
19
|
|
|
class ParallelConfiguration |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @param InputInterface $input |
|
23
|
|
|
* @return ContainerBuilder |
|
24
|
|
|
* @throws \Exception |
|
25
|
|
|
*/ |
|
26
|
58 |
|
public function buildContainer(InputInterface $input): ContainerBuilder |
|
27
|
|
|
{ |
|
28
|
58 |
|
$containerBuilder = new ContainerBuilder(); |
|
29
|
|
|
|
|
30
|
58 |
|
$this->loadYamlConfiguration($containerBuilder); |
|
31
|
58 |
|
$this->registerEventDispatcher($containerBuilder); |
|
32
|
58 |
|
$this->loadCommandLineOptions($containerBuilder, $input); |
|
33
|
|
|
|
|
34
|
58 |
|
$containerBuilder->compile(); |
|
35
|
|
|
|
|
36
|
58 |
|
$this->loadPostCompileSettings($containerBuilder, $input); |
|
37
|
|
|
|
|
38
|
58 |
|
return $containerBuilder; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param ContainerBuilder $containerBuilder |
|
43
|
|
|
* @return YamlFileLoader |
|
44
|
|
|
* @throws \Exception |
|
45
|
|
|
*/ |
|
46
|
58 |
|
protected function loadYamlConfiguration(ContainerBuilder $containerBuilder): YamlFileLoader |
|
47
|
|
|
{ |
|
48
|
58 |
|
$loader = new YamlFileLoader($containerBuilder, new FileLocator(__DIR__ . '/../Resources/config/')); |
|
49
|
58 |
|
$loader->load('configuration.yml'); |
|
50
|
58 |
|
$loader->load('file.yml'); |
|
51
|
58 |
|
$loader->load('parser.yml'); |
|
52
|
58 |
|
$loader->load('printer.yml'); |
|
53
|
58 |
|
$loader->load('process.yml'); |
|
54
|
58 |
|
$loader->load('services.yml'); |
|
55
|
58 |
|
$loader->load('test_result.yml'); |
|
56
|
58 |
|
$loader->load('test_result_container.yml'); |
|
57
|
58 |
|
$loader->load('test_result_format.yml'); |
|
58
|
|
|
|
|
59
|
58 |
|
return $loader; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param ContainerBuilder $containerBuilder |
|
64
|
|
|
* @throws \Symfony\Component\DependencyInjection\Exception\BadMethodCallException |
|
65
|
|
|
*/ |
|
66
|
58 |
|
private function registerEventDispatcher(ContainerBuilder $containerBuilder) |
|
67
|
|
|
{ |
|
68
|
58 |
|
$containerBuilder->addCompilerPass(new RegisterListenersPass()); |
|
69
|
|
|
|
|
70
|
58 |
|
$containerBuilder->setDefinition( |
|
71
|
58 |
|
'event_dispatcher', |
|
72
|
58 |
|
new Definition(ContainerAwareEventDispatcher::class, [new Reference('service_container')]) |
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
58 |
|
protected function loadCommandLineOptions(ContainerBuilder $containerBuilder, InputInterface $input) |
|
77
|
|
|
{ |
|
78
|
58 |
|
$containerBuilder->setParameter('paraunit.max_process_count', $input->getOption('parallel')); |
|
79
|
58 |
|
$containerBuilder->setParameter('paraunit.phpunit_config_filename', $input->getOption('configuration') ?? '.'); |
|
80
|
58 |
|
$containerBuilder->setParameter('paraunit.testsuite', $input->getOption('testsuite')); |
|
81
|
58 |
|
$containerBuilder->setParameter('paraunit.string_filter', $input->getArgument('stringFilter')); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
protected function loadPostCompileSettings(ContainerBuilder $container, InputInterface $input) |
|
85
|
|
|
{ |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|