Drupal Extension for Behat
Switch branches/tags
Nothing to show
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/Phase2/Behat/DrupalExtension
.gitignore
README.md
composer.json
init.php

README.md

DrupalExtension

This extension provides Behat integration with Drupal CMS projects. It provides:

  • DrupalMinkContext, which provides some useful step definitions for common Drupal functions, such as creating users and logging in.

Installation

This extension requires:

Through Composer

  1. Define dependencies in your composer.json:
   {
       "require": {
           ...
           "phase2/drupal-extension": "dev-master"
       },
       "repositories": [
         ...
         {
           "type": "vcs",
           "url": "https://github.com/phase2/behat-drupal-extension"
         }
       ]
   }
  1. Install/update your vendors
   $ curl http://getcomposer.org/installer | php
   $ php composer.phar install
  1. Activate extension in your behat.yml
   default:
     # ...
       extensions:
         Phase2\Behat\DrupalExtension\Extension:
           drupal_root: /path/to/drupal
           base_url: http://example.com/

Usage

After installing extension, there are 2 usage options available for you:

  1. Set the context class in the configuration file to use DrupalMinkContext.
   # behat.yml
   default:
     context:
       class: Phase2\Behat\DrupalExtension\Context\DrupalMinkContext

This will give you access to all of the pre-defined Drupal and Mink steps without needing to create a FeatureContext of your own.

  1. Extend Phase2\Behat\DrupalExtension\Context\DrupalMinkContext with your context or subcontext if you need additional step definitions or hooks.

Configuration

DrupalExtension comes with a flexible configuration system, that gives you the ability to configure how Drupal is used.

  • drupal_root - specifies the path to your Drupal document root.
  • base_url - specify the URL to be used when bootstrapping Drupal. If using MinkExtension, this should match the base_url in the MinkExtension settings.
  • module - specify the name of an enabled Drupal module to run the feature suite bundled with the module.