lcobucci / behat-di-builder-extension
A behat extension that allows injecting services from a container created with lcobucci/di-builder in contexts
Installs: 35 823
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 6
Requires
- php: ^8.0
- behat/behat: ^3.9
- lcobucci/di-builder: ^7.1
Requires (Dev)
- lcobucci/coding-standard: ^8.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^0.12
- phpstan/phpstan-deprecation-rules: ^0.12
- phpstan/phpstan-phpunit: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-12-21 17:50:01 UTC
README
Allows injecting services from a container created using lcobucci/di-builder
in a Behat context.
Installation
Package is available on Packagist, you can install it using Composer.
composer require --dev lcobucci/behat-di-builder-extension
Basic usage
You must first enable the extension on your behat configuration file:
default: # ... extensions: Lcobucci\DependencyInjection\Behat\BuilderExtension: ~
Then enable the use of the test container (create by the extension) in the suite configuration:
default: suites: my-suite: services: "@test_container" extensions: Lcobucci\DependencyInjection\Behat\BuilderExtension: ~
And finally inject the services into your contexts
default: suites: my-suite: services: "@test_container" contexts: - My\Lovely\Context: - "@my_service" extensions: Lcobucci\DependencyInjection\Behat\BuilderExtension: ~
Advanced configuration
You can provide the following parameters to the extension to better configure it:
- name: if you already have an extension using
test_container
- container_builder: if your application already uses
lcobucci/di-builder
and you want to use it (instead of a blank container builder) - packages: so that you can add/override service definitions for testing
Your behat.yml
would look like this with those settings:
default: suites: my-suite: services: "@my_container" contexts: - My\Lovely\Context: - "@my_service" extensions: Lcobucci\DependencyInjection\Behat\BuilderExtension: name: "my_container" container_builder: "config/container_builder.php" packages: My\DIBuilder\Package: ~ My\DIBuilder\PackageWithConstructorArguments: - "one" - "two"