Supported tags and respective
For more information about this image and its history, please see the westernmichiganuniversity/docker-drupal-module-behat repository on Bitbucket.
What is included?
This image contains the components needed to test a Drupal module project with Behat, including:
- PHP 5.6
- MySQL server
What is not included?
The image does not include Drupal Core because it assumes that you are managing your module project with Composer and have already added Drupal as a dependency. By default, the image expects to find Drupal Core in
vendor/drupal/drupal in your project directory. Likewise, if your module depends on any other Drupal modules or third-party libraries, the image expects to find them in
vendor/drupal/libraries, respectively. If your Composer configuration installs these packages to a different location, set the
DRUPAL_LIBRARIES environment variables to the corresponding paths within the container.
The image also does not include the executables for Drush (to install the module) or Behat (to run the tests), again assuming that you have already added these as dependencies. By default, Composer will place the executables at
vendor/bin/behat in your project directory. If your Composer configuration installs these executables to a different location, you can tell the container where to find them by setting the
DRUSH environment variable and overriding the container's default runtime command. For example, if your Composer configuration installs these executables in
/path/to/my/project/bin, you would run the container like so:
docker run -v /path/to/my/project:/opt/project -e DRUSH=/opt/project/bin/drush westernmichiganuniversity/drupal-module-behat /opt/project/bin/behat
If you created your project using the WMU Drupal module template, then all of the above has already been set up for you. If you did not use the template, simply run
composer require drupal/drupal:7.*,
composer require drush/drush and
composer require behat/behat to add Drupal Core, Drush and Behat to your project.
How to use this image
To test a Drupal module project with Behat:
- Map your project directory (containing
features/and your module's
.modulefiles) into the container as
- Set the
MODULEenvironment variable to the machine name of your module (i.e., the name of your
.infofile, minus the
- (optional) If you need to enable additional modules before running the test, set the
ENABLE_OTHER_MODULESenvironment variable to a list of the modules' machine names, separating each module with a space. Note that you do not need to set this for modules that are defined as dependencies in your
.infofile. For example, if your module defines actions for the Rules module—but does not actually depend on Rules—then you could set
ENABLE_OTHER_MODULES="rules"to enable the Rules module before testing those actions. In this case, you would want to add Rules to
composer.jsonfile (by running
composer require drupal/rules --dev) so that it is available for testing, but not required when deploying your module in production.
By default, on run, the container executes the command
vendor/bin/behat --no-interaction --format=junit --format=pretty in the
/opt/project directory. You can override this command by passing a new command as an argument to
Running with default options
docker run -v /path/to/my/project:/opt/project -e MODULE=my_module westernmichiganuniversity/drupal-module-behat
docker run ... westernmichiganuniversity/drupal-module-behat: Starts a Docker container using this image.
-v /path/to/my/project:/opt/project: Maps the
/path/to/my/projectdirectory on your local machine into the container as the
-e MODULE=my_module: Copies your module into the container's Drupal site as
sites/all/modules/my_moduleand enables it.
- Runs all test suites defined in
Running with additional modules enabled
docker run -v /path/to/my/project:/opt/project -e MODULE=my_module -e ENABLE_OTHER_MODULES="rules views" westernmichiganuniversity/drupal-module-behat
-e ENABLE_OTHER_MODULES="rules views": Enables the Rules and Views modules.
Running only one test case
docker run -v /path/to/my/project:/opt/project -e MODULE=my_module westernmichiganuniversity/drupal-module-behat vendor/bin/behat --no-interaction --format=junit --format=pretty features/example.feature
vendor/bin/behat --no-interaction --format=junit --format=pretty features/example.feature: Runs only the tests defined in
/path/to/my/project/features/example.featureon your local machine), rather than all test suites defined in
License information for the software contained in this image is available from:
This image is supported for use by Western Michigan University web developers on Docker version 17.03.0-ce.