diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-09-26 17:03:13 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-09-26 17:03:13 +0000 |
commit | bf7175abe5735bd304246bfc353dfdb7078f747c (patch) | |
tree | 7a35de607c383c165d30d87d99e05132fc737822 /modules/update/tests/update_test.module | |
parent | dfa38ec66cc463ea4c98028032de1a11cdccca4c (diff) | |
download | brdo-bf7175abe5735bd304246bfc353dfdb7078f747c.tar.gz brdo-bf7175abe5735bd304246bfc353dfdb7078f747c.tar.bz2 |
- Patch #253501 by dww, cwgordon7 | boombatower, Dave Reid: added tests for update.module.
Diffstat (limited to 'modules/update/tests/update_test.module')
-rw-r--r-- | modules/update/tests/update_test.module | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/update/tests/update_test.module b/modules/update/tests/update_test.module new file mode 100644 index 000000000..54e497415 --- /dev/null +++ b/modules/update/tests/update_test.module @@ -0,0 +1,50 @@ +<?php +// $Id$ + +/** + * Implement hook_menu(). + */ +function update_test_menu() { + $items = array(); + + $items['update-test'] = array( + 'title' => t('Update test'), + 'page callback' => 'update_test_mock_page', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); + + return $items; +} + +/** + * Implement hook_system_info_alter(). + * + * This checks the 'update_test_system_info' variable and sees if we need to + * alter the system info for the given $file based on the setting. The setting + * is expected to be a nested associative array. If the key '#all' is defined, + * its subarray will include .info keys and values for all modules and themes + * on the system. Otherwise, the settings array is keyed by the module or + * theme short name ($file->name) and the subarrays contain settings just for + * that module or theme. + */ +function update_test_system_info_alter(&$info, $file) { + $setting = variable_get('update_test_system_info', array()); + foreach (array('#all', $file->name) as $id) { + if (!empty($setting[$id])) { + foreach ($setting[$id] as $key => $value) { + $info[$key] = $value; + } + } + } +} + +/** + * Page callback, prints mock XML for the update module. + */ +function update_test_mock_page() { + $xml = variable_get('update_test_xml', FALSE); + // Note: this will cause an exception to occur if no variable was set and + // $file is FALSE. + readfile(drupal_get_path('module', 'update_test') . "/$xml"); +} |