|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sylius\Behat\PageObjectExtension\ServiceContainer; |
|
13
|
|
|
|
|
14
|
|
|
use Behat\Symfony2Extension\ServiceContainer\Symfony2Extension; |
|
15
|
|
|
use Behat\Testwork\ServiceContainer\Extension; |
|
16
|
|
|
use Behat\Testwork\ServiceContainer\ExtensionManager; |
|
17
|
|
|
use Sylius\Behat\PageObjectExtension\Factory\PageObjectFactory; |
|
18
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
21
|
|
|
use Symfony\Component\DependencyInjection\Parameter; |
|
22
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
23
|
|
|
use Symfony\Component\Routing\RouterInterface; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @author Arkadiusz Krakowiak <[email protected]> |
|
27
|
|
|
*/ |
|
28
|
|
|
final class PageObjectExtension implements Extension |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritdoc} |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getConfigKey() |
|
34
|
|
|
{ |
|
35
|
|
|
return 'sylius_page_object'; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* {@inheritdoc} |
|
40
|
|
|
*/ |
|
41
|
|
|
public function initialize(ExtensionManager $extensionManager) |
|
42
|
|
|
{ |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritdoc} |
|
47
|
|
|
*/ |
|
48
|
|
|
public function configure(ArrayNodeDefinition $builder) |
|
49
|
|
|
{ |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* {@inheritdoc} |
|
54
|
|
|
*/ |
|
55
|
|
|
public function load(ContainerBuilder $container, array $config) |
|
56
|
|
|
{ |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* {@inheritdoc} |
|
61
|
|
|
*/ |
|
62
|
|
|
public function process(ContainerBuilder $container) |
|
63
|
|
|
{ |
|
64
|
|
|
$router = $this->extractSymfonyApplicationRouter($container); |
|
65
|
|
|
|
|
66
|
|
|
$container |
|
67
|
|
|
->register('sylius.page_object.factory', PageObjectFactory::class) |
|
68
|
|
|
->setArguments([ |
|
69
|
|
|
new Reference('sylius.page_object.factory.inner'), |
|
70
|
|
|
new Reference('mink'), |
|
71
|
|
|
new Reference('sensio_labs.page_object_extension.class_name_resolver'), |
|
72
|
|
|
'%sensio_labs.page_object_extension.page_factory.page_parameters%', |
|
73
|
|
|
$router, |
|
74
|
|
|
]) |
|
75
|
|
|
->setDecoratedService('sensio_labs.page_object_extension.page_factory') |
|
76
|
|
|
->setPublic(false) |
|
77
|
|
|
; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param ContainerBuilder $container |
|
82
|
|
|
* |
|
83
|
|
|
* @return RouterInterface |
|
84
|
|
|
*/ |
|
85
|
|
|
private function extractSymfonyApplicationRouter(ContainerBuilder $container) |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->extractSymfonyApplicationContainer($container)->get('router'); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param ContainerBuilder $container |
|
92
|
|
|
* |
|
93
|
|
|
* @return ContainerInterface |
|
94
|
|
|
*/ |
|
95
|
|
|
private function extractSymfonyApplicationContainer(ContainerBuilder $container) |
|
96
|
|
|
{ |
|
97
|
|
|
$applicationKernel = $container->get(Symfony2Extension::KERNEL_ID); |
|
98
|
|
|
$applicationContainer = $applicationKernel->getContainer(); |
|
99
|
|
|
|
|
100
|
|
|
return clone $applicationContainer; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|