Unit testing with Behat
Behat is a BDD framework for testing your code with human-readable sentences that describes code behavior in various use cases.
Getting ready
Create an empty directory for a new project.
How to do it…
In this recipe, we will create a demonstration shopping cart extension with Behat tests.
Preparing extension structure
First, create a directory structure for your extension:
book └── cart ├── src └── features
To work with the extension as a Composer package, prepare the
book/cart/composer.json
file as follows:{ "name": "book/cart", "type": "yii2-extension", "require": { "yiisoft/yii2": "~2.0" }, "require-dev": { "phpunit/phpunit": "4.*", "behat/behat": "^3.1" }, "autoload": { "psr-4": { "book\\cart\\": "src/", "book\\cart\\features\\": "features/" } }, "extra": { "asset-installer-paths": { "npm-asset-library": "vendor/npm", "bower-asset...