1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace JsonSpec\Behat; |
4
|
|
|
|
5
|
|
|
use Behat\Behat\Context\ServiceContainer\ContextExtension; |
6
|
|
|
use \Behat\Testwork\ServiceContainer\Extension as BehatExtension; |
7
|
|
|
use Behat\Testwork\ServiceContainer\ExtensionManager; |
8
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
9
|
|
|
use Symfony\Component\Config\FileLocator; |
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
11
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
12
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
13
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
14
|
|
|
|
15
|
|
|
class Extension implements BehatExtension |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var ExtensionManager |
20
|
|
|
*/ |
21
|
|
|
private $extensionManager; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @inheritdoc |
25
|
|
|
*/ |
26
|
|
|
public function getConfigKey() |
27
|
|
|
{ |
28
|
|
|
return 'json_spec'; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @inheritdoc |
33
|
|
|
*/ |
34
|
|
|
public function configure(ArrayNodeDefinition $builder) |
35
|
|
|
{ |
36
|
|
|
$builder |
37
|
|
|
->children() |
38
|
|
|
->arrayNode('excluded_keys') |
39
|
|
|
->prototype('scalar') |
40
|
|
|
->example(array('id', 'created_at')) |
41
|
|
|
->end() |
42
|
|
|
->defaultValue(array('id', 'created_at', 'updated_at')) |
43
|
|
|
->end() |
44
|
|
|
->scalarNode('json_directory')->defaultNull()->end() |
45
|
|
|
->end(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @inheritdoc |
50
|
|
|
*/ |
51
|
|
|
public function initialize(ExtensionManager $extensionManager) |
52
|
|
|
{ |
53
|
|
|
$this->extensionManager = $extensionManager; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @inheritdoc |
58
|
|
|
*/ |
59
|
|
|
public function load(ContainerBuilder $container, array $config) |
60
|
|
|
{ |
61
|
|
|
$container->setParameter('json_spec.excluded_keys', $config['excluded_keys']); |
62
|
|
|
$container->setParameter('json_spec.json_directory', $config['json_directory']); |
63
|
|
|
|
64
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/Resources/services')); |
65
|
|
|
$loader->load('services.yml'); |
66
|
|
|
|
67
|
|
|
if (null !== $this->extensionManager->getExtension('mink')) { |
68
|
|
|
$loader->load('mink_integration.yml'); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @inheritdoc |
74
|
|
|
*/ |
75
|
|
|
public function process(ContainerBuilder $container) {} |
76
|
|
|
|
77
|
|
|
} |
78
|
|
|
|