Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / EventDispatcher / ServiceContainer / EventDispatcherExtension.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\EventDispatcher\ServiceContainer;
12
13 use Behat\Behat\EventDispatcher\Event\ExampleTested;
14 use Behat\Behat\EventDispatcher\Event\ScenarioTested;
15 use Behat\Behat\Tester\ServiceContainer\TesterExtension;
16 use Behat\Testwork\Cli\ServiceContainer\CliExtension;
17 use Behat\Testwork\EventDispatcher\ServiceContainer\EventDispatcherExtension as BaseExtension;
18 use Symfony\Component\DependencyInjection\ContainerBuilder;
19 use Symfony\Component\DependencyInjection\Definition;
20 use Symfony\Component\DependencyInjection\Reference;
21
22 /**
23  * Extends Testwork EventDispatcherExtension with additional event-dispatching testers.
24  *
25  * @author Konstantin Kudryashov <ever.zet@gmail.com>
26  */
27 class EventDispatcherExtension extends BaseExtension
28 {
29     /**
30      * {@inheritdoc}
31      */
32     public function load(ContainerBuilder $container, array $config)
33     {
34         parent::load($container, $config);
35
36         $this->loadStopOnFailureController($container);
37         $this->loadEventDispatchingBackgroundTester($container);
38         $this->loadEventDispatchingFeatureTester($container);
39         $this->loadEventDispatchingOutlineTester($container);
40         $this->loadEventDispatchingScenarioTester($container);
41         $this->loadEventDispatchingExampleTester($container);
42         $this->loadEventDispatchingStepTester($container);
43         $this->loadTickingStepTester($container);
44     }
45
46     /**
47      * Loads stop on failure controller.
48      *
49      * @param ContainerBuilder $container
50      */
51     protected function loadStopOnFailureController(ContainerBuilder $container)
52     {
53         $definition = new Definition('Behat\Behat\EventDispatcher\Cli\StopOnFailureController', array(
54             new Reference(EventDispatcherExtension::DISPATCHER_ID)
55         ));
56         $definition->addTag(CliExtension::CONTROLLER_TAG, array('priority' => 100));
57         $container->setDefinition(CliExtension::CONTROLLER_TAG . '.stop_on_failure', $definition);
58     }
59
60     /**
61      * Loads event-dispatching background tester.
62      *
63      * @param ContainerBuilder $container
64      */
65     protected function loadEventDispatchingBackgroundTester(ContainerBuilder $container)
66     {
67         $definition = new Definition('Behat\Behat\EventDispatcher\Tester\EventDispatchingBackgroundTester', array(
68             new Reference(TesterExtension::BACKGROUND_TESTER_ID),
69             new Reference(self::DISPATCHER_ID)
70         ));
71         $definition->addTag(TesterExtension::BACKGROUND_TESTER_WRAPPER_TAG, array('priority' => -9999));
72         $container->setDefinition(TesterExtension::BACKGROUND_TESTER_WRAPPER_TAG . '.event_dispatching', $definition);
73     }
74
75     /**
76      * Loads event-dispatching feature tester.
77      *
78      * @param ContainerBuilder $container
79      */
80     protected function loadEventDispatchingFeatureTester(ContainerBuilder $container)
81     {
82         $definition = new Definition('Behat\Behat\EventDispatcher\Tester\EventDispatchingFeatureTester', array(
83             new Reference(TesterExtension::SPECIFICATION_TESTER_ID),
84             new Reference(self::DISPATCHER_ID)
85         ));
86         $definition->addTag(TesterExtension::SPECIFICATION_TESTER_WRAPPER_TAG, array('priority' => -9999));
87         $container->setDefinition(TesterExtension::SPECIFICATION_TESTER_WRAPPER_TAG . '.event_dispatching', $definition);
88     }
89
90     /**
91      * Loads event-dispatching outline tester.
92      *
93      * @param ContainerBuilder $container
94      */
95     protected function loadEventDispatchingOutlineTester(ContainerBuilder $container)
96     {
97         $definition = new Definition('Behat\Behat\EventDispatcher\Tester\EventDispatchingOutlineTester', array(
98             new Reference(TesterExtension::OUTLINE_TESTER_ID),
99             new Reference(self::DISPATCHER_ID)
100         ));
101         $definition->addTag(TesterExtension::OUTLINE_TESTER_WRAPPER_TAG, array('priority' => -9999));
102         $container->setDefinition(TesterExtension::OUTLINE_TESTER_WRAPPER_TAG . '.event_dispatching', $definition);
103     }
104
105     /**
106      * Loads event-dispatching scenario tester.
107      *
108      * @param ContainerBuilder $container
109      */
110     protected function loadEventDispatchingScenarioTester(ContainerBuilder $container)
111     {
112         $definition = new Definition('Behat\Behat\EventDispatcher\Tester\EventDispatchingScenarioTester', array(
113             new Reference(TesterExtension::SCENARIO_TESTER_ID),
114             new Reference(self::DISPATCHER_ID),
115             ScenarioTested::BEFORE,
116             ScenarioTested::AFTER_SETUP,
117             ScenarioTested::BEFORE_TEARDOWN,
118             ScenarioTested::AFTER
119         ));
120         $definition->addTag(TesterExtension::SCENARIO_TESTER_WRAPPER_TAG, array('priority' => -9999));
121         $container->setDefinition(TesterExtension::SCENARIO_TESTER_WRAPPER_TAG . '.event_dispatching', $definition);
122     }
123
124     /**
125      * Loads event-dispatching example tester.
126      *
127      * @param ContainerBuilder $container
128      */
129     protected function loadEventDispatchingExampleTester(ContainerBuilder $container)
130     {
131         $definition = new Definition('Behat\Behat\EventDispatcher\Tester\EventDispatchingScenarioTester', array(
132             new Reference(TesterExtension::EXAMPLE_TESTER_ID),
133             new Reference(self::DISPATCHER_ID),
134             ExampleTested::BEFORE,
135             ExampleTested::AFTER_SETUP,
136             ExampleTested::BEFORE_TEARDOWN,
137             ExampleTested::AFTER
138         ));
139         $definition->addTag(TesterExtension::EXAMPLE_TESTER_WRAPPER_TAG, array('priority' => -9999));
140         $container->setDefinition(TesterExtension::EXAMPLE_TESTER_WRAPPER_TAG . '.event_dispatching', $definition);
141     }
142
143     /**
144      * Loads event-dispatching step tester.
145      *
146      * @param ContainerBuilder $container
147      */
148     protected function loadEventDispatchingStepTester(ContainerBuilder $container)
149     {
150         $definition = new Definition('Behat\Behat\EventDispatcher\Tester\EventDispatchingStepTester', array(
151             new Reference(TesterExtension::STEP_TESTER_ID),
152             new Reference(self::DISPATCHER_ID)
153         ));
154         $definition->addTag(TesterExtension::STEP_TESTER_WRAPPER_TAG, array('priority' => -9999));
155         $container->setDefinition(TesterExtension::STEP_TESTER_WRAPPER_TAG . '.event_dispatching', $definition);
156     }
157
158     /**
159      * Loads ticking step tester.
160      *
161      * @param ContainerBuilder $container
162      */
163     protected function loadTickingStepTester(ContainerBuilder $container)
164     {
165         if (!function_exists('pcntl_signal')) {
166             return;
167         }
168
169         $definition = new Definition('Behat\Behat\EventDispatcher\Tester\TickingStepTester', array(
170             new Reference(TesterExtension::STEP_TESTER_ID)
171         ));
172         $definition->addTag(TesterExtension::STEP_TESTER_WRAPPER_TAG, array('priority' => 9999));
173         $container->setDefinition(TesterExtension::STEP_TESTER_WRAPPER_TAG . '.ticking', $definition);
174     }
175 }