On this page
Hidden modules and themes
Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites
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() {
parent::setUp(array('xmlrpc_test'));
}
To install the test modules during the setUp phase.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion