Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Latest commit

 

History

History
55 lines (43 loc) · 1.61 KB

File metadata and controls

55 lines (43 loc) · 1.61 KB

BehatSymfonyDependencyInjectionContainerExtension

Extension to load additional dependency injection config files for behat

Inspired by FriendsOfBehat/ServiceContainerExtension

Usage

  1. Install it:

    $ composer require solutiondrive/behat-symfony-dependency-injection-container-extension --dev
  2. Enable this extension and configure Behat to use it:

    # behat.yml
    default:
        # ...
        extensions:
            solutionDrive\BehatSymfonyDependencyInjectionContainerExtension:
                identifiers:
                    solutionDrive:
                        imports:
                            - "config/solutionDrive/services.xml"
                            - "config/solutionDrive/services.yml"
                            - "config/solutionDrive/services.php"
  3. Write services file definitions:

    <!-- config/solutionDrive/services.xml -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services">
        <services>
            <service id="acme.my_service" class="Acme\MyService" />
        </services>
    </container>
    # config/solutionDrive/services.yml
    services:
        acme.my_service:
            class: Acme\MyService
    // config/solutionDrive/services.php
    use Symfony\Component\DependencyInjection\Definition;
    
    $container->setDefinition('acme.my_service', new Definition(\Acme\MyService::class));