Settings

This documentaton refers to settings provided by the WordHat extension.

Consult the Behat website for an overview of general settings, or the Mink website for settings relating to controlling a web browser.

WordHat

These are the options provided by the WordHat extension:

PaulGibbs\WordpressBehatExtension:
  default_driver: wpcli
  path: ~

  # User settings.
  users:
    admin:
      username: admin
      password: admin
    editor:
      username: editor
      password: editor
    author:
      username: author
      password: author
    contributor:
      username: contributor
      password: contributor
    subscriber:
      username: subscriber
      password: subscriber

  # WordPress settings.
  site_url: ~
  permalinks:
    author_archive: author/%s/
  database:
    restore_after_test: false
    backup_path: ~

  # Driver settings.
  wpcli:
    alias: dev
    binary: wp
Option Default value Description
default_driver “wpcli” Optional.
The WordPress driver to use (“wpcli”, “wpphp”).
path null Required.
Path to WordPress files.
users.* see example Optional.
Keys must match names of WordPress roles.
site_url null Optional.
If your WordPress is installed in a subdirectory, set this to the site_url() value. Defaults to mink.base_url.
permalinks.* see example Optional.
Permalink pattern for the specific kind of link.
%s is replaced with an ID/object name, as appropriate.
database.restore_after_test false Optional.
If true, WordHat will restore your site’s database to its initial state between feature tests.
database.backup_path see example Optional.
If restore_after_test is true, and the value is a file path, WordHat will use that as the back up to restore the database from.
If the path is a directory, then before any tests are run, WordHat will generate a database back up and store it here.
If the path has not been set, WordHat will choose its own temporary folder.
wpcli.alias null Optional.
WP-CLI alias (preferred over wpcli.path).
wpcli.binary wp Optional.
Path and name of WP-CLI binary.

Per-environment settings

Some of the settings in behat.yml are environment specific. For example, the base_url may be http://test.example.dev on your local development environment, while on a test server it might be http://test.example.com.

If you intend to run your tests on different environments, these sorts of settings should not be added to your behat.yml. Instead, they should be exported in an environment variable.

Before running tests, Behat will check the BEHAT_PARAMS environment variable and add these settings to the ones that are present in behat.yml (settings from this file takes precedence). This variable should contain a JSON object with your settings.

Example JSON object:

{
  "extensions": {
    "Behat\\MinkExtension": {
      "base_url": "http://development.dev"
    }
  }
}

To export this to the BEHAT_PARAMS environment variable on a Linux or MacOS system, squash the JSON object into a single line and surround with single quotes:

export BEHAT_PARAMS='{"extensions":{"Behat\\MinkExtension":{"base_url":"http://development.dev"}}}'