friends-of-behat / service-container-extension
Allows to declare own services inside Behat container without writing an extension.
Installs: 641 805
Dependents: 70
Suggesters: 0
Security: 0
Stars: 115
Watchers: 3
Forks: 6
Open Issues: 0
Language:Gherkin
Requires
- php: ^7.3 || ^8.0
- behat/behat: ^3.4
Requires (Dev)
- friends-of-behat/test-context: ^1.2
- vimeo/psalm: 4.1.1
README
Allows to declare own services inside Behat container without writing an extension.
Usage
-
Install it:
$ composer require friends-of-behat/service-container-extension --dev
-
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"
-
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));