Driving Drupal

jhedstrom
pfrenssen

The Drupal Driver framework is an API to interface with any given Drupal installation, regardless of the version. It currently supports Drupal 6, 7 and 8.

The Drupal Driver is at the heart of the Behat Drupal Extension, which is used to test thousands of Drupal sites around the world, including Drupal.org. The Behat Drupal Extension is also used to test Drupal distributions such as Open Atrium, Panopoly, and Open Scholar. Organisations using it include Energy.gov, Pfizer, and the European Commission. If you are using the Behat Drupal Extension, you are already using the Drupal Driver framework.

Over the past year the Drupal Driver framework has been abstracted out of the Behat extension into a standalone framework for controlling Drupal sites. In addition to being version-agnostic, the drivers are, to a certain extent, independent of the interface that is used to control Drupal. It is possible to control Drupal through the web administration interface (Blackbox driver), the command line interface (Drush driver), and the native Drupal API, with a REST-based driver coming soon.

Over the lifetime of a project, developers can be faced with the task of updating the Drupal version a website is built upon, while the user interface evolves at a different pace. By maintaining tests that are version-independent to a certain degree, the ability to confidently upgrade a site to a later version is drastically increased. Indeed, the Behat extension evolved out of the test suite created for the Drupal.org upgrade from 6 to 7.

Similarly, an API hub that communicates with various different Drupal sites of different versions that can be written in any version of Drupal (or any other PHP framework for that matter) becomes possible with the ability to control different versions of Drupal from a single codebase.

Being a standalone tool, the Drupal Driver can be integrated in any testing framework. It can be readily integrated with Behat through the Behat Drupal Extension. Being a modern namespaced PHP library it can be easily integrated with any PHP based testing system such as PHPUnit and Codeception. This also brings browser testing within reach (eg, Selenium, Phantom JS, etc via Mink).

This session is for you if you are already using the Behat extension and want to take customizations to the next level, or if you want to test Drupal using other PHP testing frameworks, or if you are writing an API that has to integrate seamlessly with different Drupal versions.

Resources:

Session Track

Coding and Development

Experience Level

Intermediate

Drupal Version