2.5 KiB
Migrating from SymfonyExtension 1.x to SymfonyExtension 2.0
Upgrade checklist
Symfony application configuration
-
Register
\FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundlebundle in your kernel in test environment. -
Load your context services definitions in
testenvironment (check installation documentation).
Behat extensions configuration
-
Remove
FriendsOfBehat\CrossContainerExtensionandFriendsOfBehat\ContextServiceExtensionfrom the extensions list. -
Integrate the configuration changes to your
FriendsOfBehat\SymfonyExtensionconfig (see configuration reference):-
kernel.envwas renamed tokernel.environment -
kernel.bootstrapwas moved tobootstrap -
env_filesetting was removed (use original Symfony bootstrap file or a custom one to load environment variables)
-
Behat suite configuration
- Replace
contexts_servicesconfiguration key from your suites configuration withcontexts.
Context service - definition
-
Make sure all your context definitions are public.
-
Remove
fob.context_servicetag from your context definitions.
Context service - dependencies
-
Remove
__symfony__.and__symfony_shared__.prefixes from your context dependencies. -
Use
behat.mink.default_sessionservice instead ofmink.default_sessionor getting the session from__behat__.minkservice. -
Inject
behat.mink.parametersservice (which is an object implementing\ArrayAccess) instead of%__behat__.mink.parameters%parameter. Removearraytypehint in the class implementation and assert it's\ArrayAccessorarrayinstead.
Exemplary upgrade
Sylius has updated from v1 to v2 in this PR.
<!-- Before -->
<service id="mink.default_session" class="Behat\Mink\Session" lazy="true" public="false">
<factory service="__behat__.mink" method="getSession" />
</service>
<service id="some_context" class="SomeContext" public="true">
<argument type="service" id="mink.default_session" />
<argument>%__behat__.mink.parameters%</argument>
<argument type="service" id="__symfony__.some_service" />
<tag name="fob.context_service" />
</service>
<!-- After -->
<service id="some_context" class="SomeContext" public="true">
<argument type="service" id="behat.mink.default_session" />
<argument type="service" id="behat.mink.parameters" />
<argument type="service" id="some_service" />
</service>