Hidden modules and themes

Last updated on
15 October 2016

Sometimes, hooks we want to test are not used in any of the core modules, or core modules do not cover all the use cases of these hooks.

However, Drupal's testing framework allows hidden modules and themes to be tested.

(See #953336: Contributed modules are not able to test theme-related functionality for testing theme-related functionality in modules.)

Creating a hidden module or theme

A hidden module or theme is just like a regular module or theme. The only difference is that it is hidden from the normal user by adding a hidden = TRUE line to the .info file.

Hidden modules should be put in the tests subdirectory of the module they are meant to test, or in the modules/simpletest/tests directory for hooks defined by core in one of the include files.

As an example, the XML-RPC Test module, that tests XML-RPC hooks, is in modules/simpletest/tests/xmlrpc_tests.module. Its info file is written this way:

name = "XML-RPC Test"
description = "Support module for XML-RPC tests according to the validator1 specification."
package = Testing
version = VERSION
core = 7.x

hidden = TRUE

The hidden = TRUE property instructs the administrative interface to hide this module from the user.

In modules/simpletest/test/xmlrpc.test, we simply have:

   * Implementation of setUp().
  function setUp() {

To install the test modules during the setUp phase.