This context use the nelmio/alice fixture loading system.
Warning : Alice context is using nelmio/alice ~2.0 since v0.6. If you have to use Alice ~1.0, use v.0.5.
Edit behat.yml
default:
# ...
suites:
default:
# ...
contexts:
- # ...
- Knp\FriendlyContexts\Context\AliceContext
extensions:
# ...
Knp\FriendlyContexts\Extension:
alice:
fixtures:
User: path/to/my/user/fixtures.yml
Product: path/to/my/product/fixtures.yml
dependencies: ~
Load a file
@alice(User) @alice(Product)
Feature: My feature
The feature description
...
Load all files
@alice(*)
Feature: My feature
The feature description
...
If, for example, you have to load a "User" alice file before a "Product" alice file, you can do it directly from the feature :
@alice(User) @alice(Product)
Feature: My feature
...
Or you can manage de dependence via your behat.yml
default:
# ...
suites:
default:
# ...
contexts:
- # ...
extensions:
# ...
Knp\FriendlyContexts\Extension:
alice:
fixtures:
User: path/to/my/user/fixtures.yml
Product: path/to/my/product/fixtures.yml
dependencies:
Product: [ User ]
# ...
All imported fixtures can be re-used in the Entity Context as object reference.
# user.yml
App\Entity\User:
user-john:
firstname: John
lastname: Doe
user-admin:
firstname: Admin
lastname: Admin
@alice(User)
Feature: My feature
The feature description
Background:
Given the following products
| name | user |
| Ball | John |
| Shoes | Admin |
...
You can add a provider via a class name or a Symfony service
default:
# ...
suites:
default:
# ...
contexts:
- # ...
extensions:
# ...
Knp\FriendlyContexts\Extension:
alice:
fixtures: #...
dependencies: # ...
providers:
- App\Alice\MyProvider # from class
- @app.alice.my_provider # from service
Files will be loaded following the order of files declaration in your behat.yml file. Tags order has no impact.