diff options
author | David Rothstein <drothstein@gmail.com> | 2014-11-05 01:45:39 -0500 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2014-11-05 01:45:39 -0500 |
commit | c990cd6bf3e409fa65bbe885dbafd7afa5144848 (patch) | |
tree | af9095c041f17b4392a8b912606143ac89313ad8 /modules/system | |
parent | 35e7cb17865a0d524b500c9318197bcf89f2ae60 (diff) | |
download | brdo-c990cd6bf3e409fa65bbe885dbafd7afa5144848.tar.gz brdo-c990cd6bf3e409fa65bbe885dbafd7afa5144848.tar.bz2 |
Issue #1355526 by cafuego, jenlampton: Added a way to determine the date a module was added so the modules page can use it for sort.
Diffstat (limited to 'modules/system')
-rw-r--r-- | modules/system/system.module | 8 | ||||
-rw-r--r-- | modules/system/system.test | 28 |
2 files changed, 36 insertions, 0 deletions
diff --git a/modules/system/system.module b/modules/system/system.module index 8940ad042..a27493579 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -2399,6 +2399,10 @@ function _system_rebuild_module_data() { continue; } + // Add the info file modification time, so it becomes available for + // contributed modules to use for ordering module lists. + $module->info['mtime'] = filemtime(dirname($module->uri) . '/' . $module->name . '.info'); + // Merge in defaults and save. $modules[$key]->info = $module->info + $defaults; @@ -2537,6 +2541,10 @@ function _system_rebuild_theme_data() { $themes[$key]->filename = $theme->uri; $themes[$key]->info = drupal_parse_info_file($theme->uri) + $defaults; + // Add the info file modification time, so it becomes available for + // contributed modules to use for ordering theme lists. + $themes[$key]->info['mtime'] = filemtime($theme->uri); + // Invoke hook_system_info_alter() to give installed modules a chance to // modify the data in the .info files if necessary. $type = 'theme'; diff --git a/modules/system/system.test b/modules/system/system.test index cae5cc789..aefbfbc46 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -556,6 +556,34 @@ class ModuleDependencyTestCase extends ModuleTestCase { $this->drupalPost(NULL, NULL, t('Uninstall')); $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.'); } + + /** + * Tests whether the correct module metadata is returned. + */ + function testModuleMetaData() { + // Generate the list of available modules. + $modules = system_rebuild_module_data(); + // Check that the mtime field exists for the system module. + $this->assertTrue(!empty($modules['system']->info['mtime']), 'The system.info file modification time field is present.'); + // Use 0 if mtime isn't present, to avoid an array index notice. + $test_mtime = !empty($modules['system']->info['mtime']) ? $modules['system']->info['mtime'] : 0; + // Ensure the mtime field contains a number that is greater than zero. + $this->assertTrue(is_numeric($test_mtime) && ($test_mtime > 0), 'The system.info file modification time field contains a timestamp.'); + } + + /** + * Tests whether the correct theme metadata is returned. + */ + function testThemeMetaData() { + // Generate the list of available themes. + $themes = system_rebuild_theme_data(); + // Check that the mtime field exists for the bartik theme. + $this->assertTrue(!empty($themes['bartik']->info['mtime']), 'The bartik.info file modification time field is present.'); + // Use 0 if mtime isn't present, to avoid an array index notice. + $test_mtime = !empty($themes['bartik']->info['mtime']) ? $themes['bartik']->info['mtime'] : 0; + // Ensure the mtime field contains a number that is greater than zero. + $this->assertTrue(is_numeric($test_mtime) && ($test_mtime > 0), 'The bartik.info file modification time field contains a timestamp.'); + } } /** |