The Drupal Extension is an integration layer between Behat, Mink Extension, and Drupal. It provides step definitions for common testing scenarios specific to Drupal sites.
The Drupal Extension 4.x supports Drupal 6, 7 and 8, utilizes Behat 3.2+ and runs on PHP 5.5+. It is compatible with Symfony components 2.x as well as 3.x so it can be used on Drupal 8.4.x.
If you're new to the Drupal Extension, we recommend starting with the Full documentation
-
Install using Composer:
mkdir projectdir cd projectdir curl -sS https://getcomposer.org/installer | php COMPOSER_BIN_DIR=bin php composer.phar require drupal/drupal-extension='~3.0'
-
In the projectdir, create a file called
behat.yml
. Below is the minimal configuration. Many more options are covered in the Full documentation
default:
suites:
default:
contexts:
- Drupal\DrupalExtension\Context\DrupalContext
extensions:
Behat\MinkExtension:
goutte: ~
base_url: http://example.org/ # Replace with your site's URL
Drupal\DrupalExtension:
blackbox: ~
-
In the projectdir, run
bin/behat --init
-
Find pre-defined steps to work with using:
bin/behat -di
-
Define your own steps in
projectdir\features\FeatureContext.php
-
Start adding your feature files to the
features
directory of your repository.
- Originally developed by Jonathan Hedstrom with great help from eliza411
- Maintainers
- Complex node creation, with field collections and entity references
- Achievements module support
- Drupal form element visibility
- Track down PHP notices
- Support for sites using basic HTTP authentication
Starting with 3.3.0 Behat Drupal Extension depends on Behat 3.2.0 which requires all callbacks to be defined as static methods.
Before 3.3.0:
/**
* @afterUserCreate
*/
public function afterUserCreate(EntityScope $scope) {
// ...
}
Starting with 3.3.0:
/**
* @afterUserCreate
*/
public static function afterUserCreate(EntityScope $scope) {
// ...
}