forked from Behatch/contexts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtension.php
64 lines (52 loc) · 1.97 KB
/
Extension.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Sanpi\Behatch;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Behat\Behat\Context\ServiceContainer\ContextExtension;
use Behat\Testwork\ServiceContainer\ExtensionManager;
use Behat\Testwork\ServiceContainer\Extension as ExtensionInterface;
class Extension implements ExtensionInterface
{
public function getConfigKey()
{
return 'behatch';
}
public function initialize(ExtensionManager $extensionManager)
{
}
public function process(ContainerBuilder $container)
{
}
public function load(ContainerBuilder $container, array $config)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/Resources/services'));
$loader->load('http_call.yml');
$this->loadClassResolver($container);
$this->loadHttpCallListener($container);
}
public function configure(ArrayNodeDefinition $builder)
{
}
private function loadClassResolver(ContainerBuilder $container)
{
$definition = new Definition('Sanpi\Behatch\Context\ContextClass\ClassResolver');
$definition->addTag(ContextExtension::CLASS_RESOLVER_TAG);
$container->setDefinition('behatch.class_resolver', $definition);
}
private function loadHttpCallListener(ContainerBuilder $container)
{
$processor = new \Behat\Testwork\ServiceContainer\ServiceProcessor;
$references = $processor->findAndSortTaggedServices($container, 'behatch.context_voter');
$definition = $container->getDefinition('behatch.context_supported.voter');
foreach ($references as $reference) {
$definition->addMethodCall('register', [$reference]);
}
}
public function getCompilerPasses()
{
return [];
}
}