Skip to content
A collection of traits that help to quickly develop custom Context classes for testing Drupal sites using Behat.
PHP Gherkin
Branch: 8.x-1.x
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.drone.yml
.gitignore
CONTRIBUTING.md
LICENSE.txt
README.md
behat.yml.dist
composer.json
docker-compose.yml
grumphp.yml.dist
runner.yml.dist

README.md

Behat traits

A collection of traits that help to quickly develop custom Context classes for testing Drupal sites using Behat.

Requirements

This depends on the following software:

Installation

Install the package and its dependencies. Since this is intended to be used for testing, use the --dev option to install it as a development dependency:

$ composer require --dev drupaltest/behat-traits

Usage

The project offers a number of traits that help to quickly create custom Behat Context classes by performing common tasks that are typically needed in step definitions for Drupal projects.

For some examples on how this can be used, see the test contexts in the ./src/Context/ folder.

Setting up a development environment

If you want to contribute to Behat Traits you can install a local development environment for it by executing the following steps:

Step 0: Clone the repository

$ git clone https://github.com/drupaltest/behat-traits.git
$ cd behat-traits

Using a local LAMP stack

Step 1: Install dependencies

$ composer install

Step 2: Configure the environment

Copy runner.yml.dist to runner.yml and change the configuration to match your local environment. Typically you will need to specify localhost as your database host, and change your base URL and database credentials.

Step 3: Build

$ ./vendor/bin/run drupal:site-setup

This will symlink the module in the proper directory within the test environment and perform token substitution in test configuration files.

Step 4: Install

$ ./vendor/bin/run drupal:site-install

Your test site will be available at ./build.

Using Docker Compose

Step 0: Download images

$ docker-compose up -d

Step 1: Install dependencies

$ docker-compose exec web composer install

Step 2: Configure the environment

Copy runner.yml.dist to runner.yml and change the configuration to match your local environment if needed. Usually this can be skipped since the module ships with default configuration that matches the Docker environment.

Step 3: Build

$ docker-compose exec web ./vendor/bin/run drupal:site-setup

This will symlink the module in the proper directory within the test environment and perform token substitution in test configuration files.

Step 4: Install

$ docker-compose exec web ./vendor/bin/run drupal:site-install

Your test site will be available at http://localhost:8080/build.

Running tests

Using a local LAMP stack

Coding standards

$ ./vendor/bin/grumphp run

Behat tests

$ ./vendor/bin/behat

Using Docker Compose

Coding standards

$ docker-compose exec web ./vendor/bin/grumphp run

Behat tests

$ docker-compose exec web ./vendor/bin/behat
You can’t perform that action at this time.