4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\Hook\ServiceContainer;
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;
21 * Extends Testwork HookExtension with additional behat services.
23 * @author Konstantin Kudryashov <ever.zet@gmail.com>
25 final class HookExtension extends BaseExtension
30 public function load(ContainerBuilder $container, array $config)
32 parent::load($container, $config);
34 $this->loadAnnotationReader($container);
38 * Loads hookable testers.
40 * @param ContainerBuilder $container
42 protected function loadHookableTesters(ContainerBuilder $container)
44 parent::loadHookableTesters($container);
46 $definition = new Definition('Behat\Behat\Hook\Tester\HookableFeatureTester', array(
47 new Reference(TesterExtension::SPECIFICATION_TESTER_ID),
48 new Reference(self::DISPATCHER_ID)
50 $definition->addTag(TesterExtension::SPECIFICATION_TESTER_WRAPPER_TAG, array('priority' => 9999));
51 $container->setDefinition(TesterExtension::SPECIFICATION_TESTER_WRAPPER_TAG . '.hookable', $definition);
53 $definition = new Definition('Behat\Behat\Hook\Tester\HookableScenarioTester', array(
54 new Reference(TesterExtension::SCENARIO_TESTER_ID),
55 new Reference(self::DISPATCHER_ID)
58 $definition->addTag(TesterExtension::SCENARIO_TESTER_WRAPPER_TAG, array('priority' => 9999));
59 $container->setDefinition(TesterExtension::SCENARIO_TESTER_WRAPPER_TAG . '.hookable', $definition);
61 $definition = new Definition('Behat\Behat\Hook\Tester\HookableScenarioTester', array(
62 new Reference(TesterExtension::EXAMPLE_TESTER_ID),
63 new Reference(self::DISPATCHER_ID)
66 $definition->addTag(TesterExtension::EXAMPLE_TESTER_WRAPPER_TAG, array('priority' => 9999));
67 $container->setDefinition(TesterExtension::EXAMPLE_TESTER_WRAPPER_TAG . '.hookable', $definition);
69 $definition = new Definition('Behat\Behat\Hook\Tester\HookableStepTester', array(
70 new Reference(TesterExtension::STEP_TESTER_ID),
71 new Reference(self::DISPATCHER_ID)
73 $definition->addTag(TesterExtension::STEP_TESTER_WRAPPER_TAG, array('priority' => 9999));
74 $container->setDefinition(TesterExtension::STEP_TESTER_WRAPPER_TAG . '.hookable', $definition);
78 * Loads hook annotation reader.
80 * @param ContainerBuilder $container
82 private function loadAnnotationReader(ContainerBuilder $container)
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);