Skip to content
📻 Allows to declare own services inside Behat container without writing an extension.
Branch: master
Clone or download
pamil Merge pull request #23 from pamil/maintenance
Remove unnecessary dev dependency
Latest commit 5c8ab1b Feb 13, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
features
src/ServiceContainer
.gitattributes
.gitignore Initialize Behat Jul 27, 2016
.travis.yml Remove unnecessary dev dependency Feb 13, 2018
LICENSE Happy new year! Jan 16, 2017
README.md
behat.yml.dist
composer.json Remove unnecessary dev dependency Feb 13, 2018

README.md

Service Container Extension License Version Build status on Linux Scrutinizer Quality Score

Allows to declare own services inside Behat container without writing an extension.

Usage

  1. Install it:

    $ composer require friends-of-behat/service-container-extension --dev
  2. Enable this extension and configure Behat to use it:

    # behat.yml
    default:
        # ...
        extensions:
            FriendsOfBehat\ServiceContainerExtension:
                imports:
                    - "features/bootstrap/config/services.xml"
                    - "features/bootstrap/config/services.yml"
                    - "features/bootstrap/config/services.php"
  3. Write services files definitions:

    <!-- features/bootstrap/config/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>
    # features/bootstrap/config/services.yml
    services:
        acme.my_service:
            class: Acme\MyService
    // features/bootstrap/config/services.php
    use Symfony\Component\DependencyInjection\Definition;
    
    $container->setDefinition('acme.my_service', new Definition(\Acme\MyService::class));
You can’t perform that action at this time.