Symfony2Extension
Provides integration layer for Symfony2:
- Complete integration into Symfony2 bundle structure - you can run isolated bundle suite by bundle shortname, classname or even full path
KernelAwareInterface
, which provides initialized and booted kernel instance for your contexts- Additional
symfony2
session (sets as default) for Mink (ifMinkExtension
is installed)
between Behat 2.4+ and Symfony2+
Installation
This extension requires:
- Behat 2.4+
Through PHAR
Download Behat phar from:
After downloading and placing behat.phar into project directory, you need to download and
activate Symfony2Extension
:
-
Put downloaded phar package into folder with Behat
-
Tell Behat about extensions with
behat.yml
configuration:# behat.yml defaults: # ... extensions: symfony2_extension.phar: ~
For all configuration options, check extension configuration class.
Through Composer
-
Set dependencies in your
composer.json
:{ "require": { ... "behat/symfony2-extension": "*" } }
-
Install/update your vendors:
$> curl http://getcomposer.org/installer | php $> php composer.phar install
-
Activate extension in your
behat.yml
:# behat.yml defaults: # ... extensions: Behat\Symfony2Extension\Extension: ~
Usage
After installing extension, there would be 2 usage options available for you:
- If you're on the php 5.4+, you can simply use
Behat\Symfony2Extension\Context\KernelDictionary
trait inside yourFeatureContext
or any of its subcontexts. This trait will providegetKernel()
andgetContainer()
methods for you. - Implementing
Behat\Symfony2Extension\Context\KernelAwareInterface
with your context or its subcontexts. This will give you more customization options. Also, you can use this mechanism on multiple contexts avoiding the need to call parent contexts from subcontexts when only thing you need is mink instance.
There's common thing between those 2 methods. In each of those, target context will implement
setKernel(HttpKernel $kernel)
method. This method would be automatically called immediately after
each context creation before each scenario. Note that this kernel will be automatically
rebooted between scenarios, so your scenarios would have almost absolutely isolated state.
Initialize bundle suite
Just run:
$> php behat.phar --init @YouBundleName
Run bundle suite
$> php behat.phar @YouBundleName
symfony2
Mink session
Using Symfony2Extension comes bundled with custom symfony2
session for Mink, which is disabled
by default. In order to use it, you should download/install/activate MinkExtension and enabling
mink_driver
in Symfony2Extension:
# behat.yml
defaults:
# ...
extensions:
symfony2_extension.phar:
mink_driver: true
mink_extension.phar: ~
Also, you can make symfony2
session default one by setting default_session
option in
MinkExtension:
# behat.yml
defaults:
# ...
extensions:
symfony2_extension.phar:
mink_driver: true
mink_extension.phar:
default_session: 'symfony2'
Copyright
Copyright (c) 2012 Konstantin Kudryashov (ever.zet). See LICENSE for details.
Contributors
- Konstantin Kudryashov everzet [lead developer]
- Other awesome developers
Sponsors
- knpLabs knpLabs [main sponsor]