This project is not covered by Drupal’s security advisory policy.

Integration of the PHPUnit framework, for unit testing and test driven development, with Drupal.

Stable release 5.x-1 is now available.

A great series of blog posts by Pat Shaughnessy on Test Driven Development for Drupal 6 using PHPUnit are available. Take a look at the first: Why to use TDD with Drupal.

Development for the next release continues in the CVS branch DRUPAL-5--2. See the nightly snapshots of this development branch as 5.x-2.x-dev in the releases section below.

Already included in Drupal 5.x-2.x-dev:

  • New test case class to test module implementations of Drupal hook functions. This class is called DrupalTest_Hook_TestCase and already has these test methods:
    • DrupalTest_Hook_TestCase::test_hook_menu() - assertions checking cached and non-cached items, 'callback' function exists, menu 'type' matches a menu module defined constant
    • DrupalTest_Hook_TestCase::test_hook_forms() - assertions checking 'callback' function exists

Considering and/or working on the following:

  • Achieving test isolation by setting up a test database before running tests - see blog post Using transactions in a separate database with Drupal PHPUnit tests by Pat Shaughnessy and Bringing test driven development to Drupal 5 by Mark Bennett.
  • A configuration settings mechanism, that works with command line interface execution, to allow updates outside the CVS controlled code files of $_SERVER array values used during bootstrap - i.e. $_SERVER['HTTP_HOST']. This may involve a configuration.ini type file.
  • An interface to execute tests using a call to the web server.

If you have any suggestions, feel free to add an issue to the issues queue, but be sure to check if someone has already posted a similar issue already. If so, you can always add a comment to the existing issue outlining your request.

Project information

Releases