Testing Drupal install and update hooks

March 04, 2014

When you’re building a big site, it’s important for deployment of changes to be repeatable and testable across environments.

Features can be a bit of a pain, especially handling variables in strongarm, so until Drupal 8 configuration management solves everything, the more change you can put into install and update hooks the better.

The trouble is that you’ll want to test those install hooks, which means running them again, and tweaking them as you go, and it’s a bit of a palaver to disable, uninstall and reinstall those modules, or run a full site install.

As always when developing Drupal, Drush is your friend:

drush ev "module_load_include('install', 'mymodule');mymodule_install();"

drush ev "module_load_include('install', 'mymodule');mymodule_update_7101();"