Download the PHP package mvlabs/zf2behat-extension without Composer
On this page you can find all versions of the php package mvlabs/zf2behat-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mvlabs/zf2behat-extension
More information about mvlabs/zf2behat-extension
Files in mvlabs/zf2behat-extension
Package zf2behat-extension
Short Description Zend Framework 2 extension for Behat
License MIT
Informations about the package zf2behat-extension
mvlabs/zf2behat-extension
Behat extension for Zend Framework 2 inspired by Symfony2extension by Konstantin Kudryashov.
Behat (http://behat.org/) is a php framework for Behavior Driven Development. This extension allows you to use it in your Zend Framework 2 projects. It initializes Behat, allowing you to quickly use your Gherking features within ZF2.
1.Requirements
This extension is installed through composer and has following dependencies:
Composer will take care of installing these for you (see below).
2.Installation
In order to install this extension, you only need to add the following in your Zend Framework 2 composer.json:
and then run composer.phar install (or update). At this point, you need to create a file named behat.yml in your application root folder with following content:
3.Usage
If you don't have an existing test suite, please proceed to 4.Initialization within a Module. Otherwise, you can use this extension within your existing test suite in 2 different ways:
- If you are using php version 5.4+, you can use MvLabs\Zf2BehatExtension\Context\Zf2Dictionary trait which provides basic ZendFramework 2 functionality. This functionality can only be used in one Context though.
- You can implement the MvLabs\Zf2BehatExtension\Context\Zf2AwareContextInterface for every context, avoiding to call parent context from subcontexts.
Both methods call a method setZf2App(Application $zf2Application) needed to set in a private property Zend\Mvc\Application to be reused on every step needed
4.Initialization inside a Module
In order to initialize your feature suite inside a Zend Framework 2 module, you need to execute:
So, for example, if you want to initialize the skeleton application, you could just do from your application root directory:
After the command is executed it will create a Features folder inside your module with a extension ready FeatureContext inside the Context subfolder. You should see following output in console:
5.Running your features
Now that you have your Features directory within your module source folder (module/
At this point, you only need to run:
to run the feature against your module.
6.Feature profiles
If you often find yourself running a specific module suite it's possible to set a module parameter inside a profile in your behat.yml file like in the example below:
You can then just call behat without arguments:
Within a profile you can use a specific Zend Framework config/application.config.php file, through the following:
7.Multiple feature profiles
You can also use multiple profiles, such in the example below:
After setting those profiles, you can your Albums module suite executing:
8.Specific Feature Execution
You can run specific features specifying file name:
9.Appication Level Feature Suite
If you don't want to use module-centric structure it's possible maitain an application structure specifing a features path and context class in your behat.yml file like in the example:
Using this path you shuold only remember to add your context class in the autoloader.
10.Configuration Parameters
Supported options for profiles are:
- module - set the module to be runned for a specific profile (only one module per profile is currently supported)
- config - set a custom configuration file. if it is not specified config/application.config.php will be loaded