1 | <?php |
||
2 | /* |
||
3 | * This file is part of the Noiselabs ZfTestCase Behat Extension. |
||
4 | * |
||
5 | * (c) Vítor Brandão <[email protected]> |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | */ |
||
10 | |||
11 | namespace Noiselabs\Behat\ZfTestCaseExtension\ServiceContainer; |
||
12 | |||
13 | use Behat\Behat\Context\ServiceContainer\ContextExtension; |
||
14 | use Behat\Testwork\ServiceContainer\Extension; |
||
15 | use Behat\Testwork\ServiceContainer\ExtensionManager; |
||
16 | use Noiselabs\Behat\ZfTestCaseExtension\Context\Initializer\ZfTestCaseAwareInitializer; |
||
17 | use Noiselabs\Behat\ZfTestCaseExtension\TestCase\HttpControllerTestCase; |
||
18 | use Noiselabs\Behat\ZfTestCaseExtension\TestCase\HttpControllerTestCaseFactory; |
||
19 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
||
20 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
21 | use Symfony\Component\DependencyInjection\Reference; |
||
22 | |||
23 | /** |
||
24 | * @author Vítor Brandão <[email protected]> |
||
25 | */ |
||
26 | class ZfTestCaseExtension implements Extension |
||
27 | { |
||
28 | const EXTENSION_ID = 'noiselabs_zf_test_case'; |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | public function process(ContainerBuilder $container) |
||
34 | { |
||
35 | // TODO: Implement process() method. |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | public function getConfigKey() |
||
42 | { |
||
43 | return self::EXTENSION_ID; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function initialize(ExtensionManager $extensionManager) |
||
50 | { |
||
51 | // TODO: Implement initialize() method. |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function configure(ArrayNodeDefinition $builder) |
||
58 | { |
||
59 | $builder |
||
60 | ->addDefaultsIfNotSet() |
||
61 | ->children() |
||
62 | ->scalarNode('configuration')->info('Path to config path of Zend application')->end() |
||
63 | ->end(); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function load(ContainerBuilder $container, array $config) |
||
70 | { |
||
71 | $this->loadHttpControllerTestCase($container, $config); |
||
72 | $this->loadContextInitializer($container); |
||
73 | } |
||
74 | |||
75 | private function loadHttpControllerTestCase(ContainerBuilder $container, array $config) |
||
76 | { |
||
77 | $container |
||
78 | ->register(self::EXTENSION_ID . '.http_controller_test_case', HttpControllerTestCase::class) |
||
79 | ->setFactory([HttpControllerTestCaseFactory::class, 'create']) |
||
80 | ->addArgument($config['configuration']); |
||
81 | } |
||
82 | |||
83 | private function loadContextInitializer(ContainerBuilder $container) |
||
84 | { |
||
85 | $container |
||
86 | ->register(self::EXTENSION_ID . '.context_initializer', ZfTestCaseAwareInitializer::class) |
||
87 | ->addArgument(new Reference(self::EXTENSION_ID . '.http_controller_test_case')) |
||
88 | ->addTag(ContextExtension::INITIALIZER_TAG); |
||
89 | } |
||
90 | } |