Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Hook / ServiceContainer / HookExtension.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
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 Behat\Behat\Hook\ServiceContainer;
12
13 use Behat\Behat\Context\ServiceContainer\ContextExtension;
14 use Behat\Behat\Tester\ServiceContainer\TesterExtension;
15 use Behat\Testwork\Hook\ServiceContainer\HookExtension as BaseExtension;
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 use Symfony\Component\DependencyInjection\Definition;
18 use Symfony\Component\DependencyInjection\Reference;
19
20 /**
21  * Extends Testwork HookExtension with additional behat services.
22  *
23  * @author Konstantin Kudryashov <ever.zet@gmail.com>
24  */
25 final class HookExtension extends BaseExtension
26 {
27     /**
28      * {@inheritdoc}
29      */
30     public function load(ContainerBuilder $container, array $config)
31     {
32         parent::load($container, $config);
33
34         $this->loadAnnotationReader($container);
35     }
36
37     /**
38      * Loads hookable testers.
39      *
40      * @param ContainerBuilder $container
41      */
42     protected function loadHookableTesters(ContainerBuilder $container)
43     {
44         parent::loadHookableTesters($container);
45
46         $definition = new Definition('Behat\Behat\Hook\Tester\HookableFeatureTester', array(
47             new Reference(TesterExtension::SPECIFICATION_TESTER_ID),
48             new Reference(self::DISPATCHER_ID)
49         ));
50         $definition->addTag(TesterExtension::SPECIFICATION_TESTER_WRAPPER_TAG, array('priority' => 9999));
51         $container->setDefinition(TesterExtension::SPECIFICATION_TESTER_WRAPPER_TAG . '.hookable', $definition);
52
53         $definition = new Definition('Behat\Behat\Hook\Tester\HookableScenarioTester', array(
54                 new Reference(TesterExtension::SCENARIO_TESTER_ID),
55                 new Reference(self::DISPATCHER_ID)
56             )
57         );
58         $definition->addTag(TesterExtension::SCENARIO_TESTER_WRAPPER_TAG, array('priority' => 9999));
59         $container->setDefinition(TesterExtension::SCENARIO_TESTER_WRAPPER_TAG . '.hookable', $definition);
60
61         $definition = new Definition('Behat\Behat\Hook\Tester\HookableScenarioTester', array(
62                 new Reference(TesterExtension::EXAMPLE_TESTER_ID),
63                 new Reference(self::DISPATCHER_ID)
64             )
65         );
66         $definition->addTag(TesterExtension::EXAMPLE_TESTER_WRAPPER_TAG, array('priority' => 9999));
67         $container->setDefinition(TesterExtension::EXAMPLE_TESTER_WRAPPER_TAG . '.hookable', $definition);
68
69         $definition = new Definition('Behat\Behat\Hook\Tester\HookableStepTester', array(
70             new Reference(TesterExtension::STEP_TESTER_ID),
71             new Reference(self::DISPATCHER_ID)
72         ));
73         $definition->addTag(TesterExtension::STEP_TESTER_WRAPPER_TAG, array('priority' => 9999));
74         $container->setDefinition(TesterExtension::STEP_TESTER_WRAPPER_TAG . '.hookable', $definition);
75     }
76
77     /**
78      * Loads hook annotation reader.
79      *
80      * @param ContainerBuilder $container
81      */
82     private function loadAnnotationReader(ContainerBuilder $container)
83     {
84         $definition = new Definition('Behat\Behat\Hook\Context\Annotation\HookAnnotationReader');
85         $definition->addTag(ContextExtension::ANNOTATION_READER_TAG, array('priority' => 50));
86         $container->setDefinition(ContextExtension::ANNOTATION_READER_TAG . '.hook', $definition);
87     }
88 }