1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the ExcludeSpecificationsExtension package. |
7
|
|
|
* |
8
|
|
|
* (c) Kamil Kokot <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace FriendsOfBehat\ExcludeSpecificationsExtension\ServiceContainer; |
15
|
|
|
|
16
|
|
|
use Behat\Testwork\ServiceContainer\Extension; |
17
|
|
|
use Behat\Testwork\ServiceContainer\ExtensionManager; |
18
|
|
|
use FriendsOfBehat\ExcludeSpecificationsExtension\Locator\ExcludingSpecificationLocator; |
19
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
21
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
22
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
23
|
|
|
|
24
|
|
|
final class ExcludeSpecificationsExtension implements Extension |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
|
|
public function getConfigKey(): string |
30
|
|
|
{ |
31
|
|
|
return 'fob_exclude_specifications'; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
public function initialize(ExtensionManager $extensionManager): void |
38
|
|
|
{ |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public function configure(ArrayNodeDefinition $builder): void |
45
|
|
|
{ |
46
|
|
|
$builder |
47
|
|
|
->children() |
48
|
|
|
->arrayNode('features') |
49
|
|
|
->performNoDeepMerging() |
50
|
|
|
->prototype('scalar')->end() |
51
|
|
|
->end() |
52
|
|
|
->end() |
53
|
|
|
; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
*/ |
59
|
|
|
public function load(ContainerBuilder $container, array $config): void |
60
|
|
|
{ |
61
|
|
|
$definition = new Definition(ExcludingSpecificationLocator::class, [ |
62
|
|
|
new Reference('specifications.locator.filesystem_feature.excluding.inner'), |
63
|
|
|
$this->getAbsoluteSkippedPaths($config['features'], $container->getParameter('paths.base')) |
64
|
|
|
]); |
65
|
|
|
|
66
|
|
|
$definition->setDecoratedService('specifications.locator.filesystem_feature'); |
67
|
|
|
$definition->setPublic(false); |
68
|
|
|
|
69
|
|
|
$container->setDefinition('specifications.locator.filesystem_feature.excluding', $definition); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* {@inheritdoc} |
74
|
|
|
*/ |
75
|
|
|
public function process(ContainerBuilder $container): void |
76
|
|
|
{ |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param array $skippedPaths |
81
|
|
|
* @param string $basePath |
82
|
|
|
* |
83
|
|
|
* @return array |
84
|
|
|
*/ |
85
|
|
|
private function getAbsoluteSkippedPaths(array $skippedPaths, string $basePath): array |
86
|
|
|
{ |
87
|
|
|
return array_map(function (string $skippedPath) use ($basePath): string { |
88
|
|
|
return $basePath . '/' . $skippedPath; |
89
|
|
|
}, $skippedPaths); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|