summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-12-11 00:12:37 -0600
committerwebchick <webchick@24967.no-reply.drupal.org>2011-12-11 00:12:37 -0600
commit11d884bee7d0e00ede4cc0c3c147d787292b9b29 (patch)
tree6a0abc1a72734a854aac6b6f351d9f6b472402a8 /modules
parenta2588037892138ab71f6249816fd3c909fa2ee3d (diff)
downloadbrdo-11d884bee7d0e00ede4cc0c3c147d787292b9b29.tar.gz
brdo-11d884bee7d0e00ede4cc0c3c147d787292b9b29.tar.bz2
Issue #953336 by sun: Fixed Contributed modules are not able to test theme-related functionality.
Diffstat (limited to 'modules')
-rw-r--r--modules/block/block.test4
-rw-r--r--modules/block/tests/block_test.module8
-rw-r--r--modules/block/tests/themes/block_test_theme/block_test_theme.info14
-rw-r--r--modules/block/tests/themes/block_test_theme/page.tpl.php78
-rw-r--r--modules/simpletest/tests/theme.test2
-rw-r--r--modules/simpletest/tests/theme_test.module8
-rw-r--r--modules/simpletest/tests/themes/test_theme/template.php21
-rw-r--r--modules/simpletest/tests/themes/test_theme/test_theme.info16
-rw-r--r--modules/system/system.api.php19
-rw-r--r--modules/system/system.module12
-rw-r--r--modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info4
-rw-r--r--modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info5
-rw-r--r--modules/update/tests/update_test.module9
13 files changed, 200 insertions, 0 deletions
diff --git a/modules/block/block.test b/modules/block/block.test
index 9639b2c10..323034062 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -764,6 +764,10 @@ class BlockHiddenRegionTestCase extends DrupalWebTestCase {
);
}
+ function setUp() {
+ parent::setUp(array('block_test'));
+ }
+
/**
* Tests that hidden regions do not inherit blocks when a theme is enabled.
*/
diff --git a/modules/block/tests/block_test.module b/modules/block/tests/block_test.module
index 2abc433c9..5e06d5cf5 100644
--- a/modules/block/tests/block_test.module
+++ b/modules/block/tests/block_test.module
@@ -6,6 +6,14 @@
*/
/**
+ * Implements hook_system_theme_info().
+ */
+function block_test_system_theme_info() {
+ $themes['block_test_theme'] = drupal_get_path('module', 'block_test') . '/themes/block_test_theme/block_test_theme.info';
+ return $themes;
+}
+
+/**
* Implements hook_block_info().
*/
function block_test_block_info() {
diff --git a/modules/block/tests/themes/block_test_theme/block_test_theme.info b/modules/block/tests/themes/block_test_theme/block_test_theme.info
new file mode 100644
index 000000000..06b6e995f
--- /dev/null
+++ b/modules/block/tests/themes/block_test_theme/block_test_theme.info
@@ -0,0 +1,14 @@
+name = Block test theme
+description = Theme for testing the block system
+core = 7.x
+hidden = TRUE
+
+regions[sidebar_first] = Left sidebar
+regions_hidden[] = sidebar_first
+regions[sidebar_second] = Right sidebar
+regions_hidden[] = sidebar_second
+regions[content] = Content
+regions[header] = Header
+regions[footer] = Footer
+regions[highlighted] = Highlighted
+regions[help] = Help
diff --git a/modules/block/tests/themes/block_test_theme/page.tpl.php b/modules/block/tests/themes/block_test_theme/page.tpl.php
new file mode 100644
index 000000000..ba72882ef
--- /dev/null
+++ b/modules/block/tests/themes/block_test_theme/page.tpl.php
@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * @file
+ * Custom theme implementation to display a single Drupal page without
+ * sidebars. The sidebars are hidden by regions_hidden for this theme, so
+ * the default page.tpl.php will not work without throwing exceptions.
+ */
+?>
+
+ <div id="page-wrapper"><div id="page">
+
+ <div id="header"><div class="section clearfix">
+
+ <?php if ($logo): ?>
+ <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
+ <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
+ </a>
+ <?php endif; ?>
+
+ <?php if ($site_name || $site_slogan): ?>
+ <div id="name-and-slogan">
+ <?php if ($site_name): ?>
+ <?php if ($title): ?>
+ <div id="site-name"><strong>
+ <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
+ </strong></div>
+ <?php else: /* Use h1 when the content title is empty */ ?>
+ <h1 id="site-name">
+ <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
+ </h1>
+ <?php endif; ?>
+ <?php endif; ?>
+
+ <?php if ($site_slogan): ?>
+ <div id="site-slogan"><?php print $site_slogan; ?></div>
+ <?php endif; ?>
+ </div> <!-- /#name-and-slogan -->
+ <?php endif; ?>
+
+ <?php print render($page['header']); ?>
+
+ </div></div> <!-- /.section, /#header -->
+
+ <?php if ($main_menu || $secondary_menu): ?>
+ <div id="navigation"><div class="section">
+ <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Main menu'))); ?>
+ <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Secondary menu'))); ?>
+ </div></div> <!-- /.section, /#navigation -->
+ <?php endif; ?>
+
+ <?php if ($breadcrumb): ?>
+ <div id="breadcrumb"><?php print $breadcrumb; ?></div>
+ <?php endif; ?>
+
+ <?php print $messages; ?>
+
+ <div id="main-wrapper"><div id="main" class="clearfix">
+
+ <div id="content" class="column"><div class="section">
+ <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
+ <a id="main-content"></a>
+ <?php print render($title_prefix); ?>
+ <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
+ <?php print render($title_suffix); ?>
+ <?php if ($tabs = render($tabs)): ?><div class="tabs"><?php print $tabs; ?></div><?php endif; ?>
+ <?php print render($page['help']); ?>
+ <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
+ <?php print render($page['content']); ?>
+ <?php print $feed_icons; ?>
+ </div></div> <!-- /.section, /#content -->
+ </div></div> <!-- /#main, /#main-wrapper -->
+
+ <div id="footer"><div class="section">
+ <?php print render($page['footer']); ?>
+ </div></div> <!-- /.section, /#footer -->
+
+ </div></div> <!-- /#page, /#page-wrapper -->
diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test
index ea0f257dd..d54885099 100644
--- a/modules/simpletest/tests/theme.test
+++ b/modules/simpletest/tests/theme.test
@@ -9,6 +9,8 @@
* Unit tests for the Theme API.
*/
class ThemeUnitTest extends DrupalWebTestCase {
+ protected $profile = 'testing';
+
public static function getInfo() {
return array(
'name' => 'Theme API',
diff --git a/modules/simpletest/tests/theme_test.module b/modules/simpletest/tests/theme_test.module
index 160d192dd..9cec5381d 100644
--- a/modules/simpletest/tests/theme_test.module
+++ b/modules/simpletest/tests/theme_test.module
@@ -1,6 +1,14 @@
<?php
/**
+ * Implements hook_system_theme_info().
+ */
+function theme_test_system_theme_info() {
+ $themes['test_theme'] = drupal_get_path('module', 'theme_test') . '/themes/test_theme/test_theme.info';
+ return $themes;
+}
+
+/**
* Implements hook_menu().
*/
function theme_test_menu() {
diff --git a/modules/simpletest/tests/themes/test_theme/template.php b/modules/simpletest/tests/themes/test_theme/template.php
new file mode 100644
index 000000000..ef8118a6d
--- /dev/null
+++ b/modules/simpletest/tests/themes/test_theme/template.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Tests a theme overriding a suggestion of a base theme hook.
+ */
+function test_theme_breadcrumb__suggestion($variables) {
+ // Tests that preprocess functions for the base theme hook get called even
+ // when the suggestion has an implementation.
+ return 'test_theme_breadcrumb__suggestion: ' . $variables['theme_test_preprocess_breadcrumb'];
+}
+
+/**
+ * Tests a theme implementing an alter hook.
+ *
+ * The confusing function name here is due to this being an implementation of
+ * the alter hook invoked when the 'theme_test' module calls
+ * drupal_alter('theme_test_alter').
+ */
+function test_theme_theme_test_alter_alter(&$data) {
+ $data = 'test_theme_theme_test_alter_alter was invoked';
+}
diff --git a/modules/simpletest/tests/themes/test_theme/test_theme.info b/modules/simpletest/tests/themes/test_theme/test_theme.info
new file mode 100644
index 000000000..dd5584b0b
--- /dev/null
+++ b/modules/simpletest/tests/themes/test_theme/test_theme.info
@@ -0,0 +1,16 @@
+name = Test theme
+description = Theme for testing the theme system
+core = 7.x
+hidden = TRUE
+
+; Normally, themes may list CSS files like this, and if they exist in the theme
+; folder, then they get added to the page. If they have the same file name as a
+; module CSS file, then the theme's version overrides the module's version, so
+; that the module's version is not added to the page. Additionally, a theme may
+; have an entry like this one, without having the corresponding CSS file in the
+; theme's folder, and in this case, it just stops the module's version from
+; being loaded, and does not replace it with an alternate version. We have this
+; here in order for a test to ensure that this correctly prevents the module
+; version from being loaded, and that errors aren't caused by the lack of this
+; file within the theme folder.
+stylesheets[all][] = system.base.css
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index f241eea78..e2fe6c619 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -1907,6 +1907,25 @@ function hook_module_implements_alter(&$implementations, $hook) {
}
/**
+ * Return additional themes provided by modules.
+ *
+ * Only use this hook for testing purposes. Use a hidden MYMODULE_test.module
+ * to implement this hook. Testing themes should be hidden, too.
+ *
+ * This hook is invoked from _system_rebuild_theme_data() and allows modules to
+ * register additional themes outside of the regular 'themes' directories of a
+ * Drupal installation.
+ *
+ * @return
+ * An associative array. Each key is the system name of a theme and each value
+ * is the corresponding path to the theme's .info file.
+ */
+function hook_system_theme_info() {
+ $themes['mymodule_test_theme'] = drupal_get_path('module', 'mymodule') . '/mymodule_test_theme/mymodule_test_theme.info';
+ return $themes;
+}
+
+/**
* Alter the information parsed from module and theme .info files
*
* This hook is invoked in _system_rebuild_module_data() and in
diff --git a/modules/system/system.module b/modules/system/system.module
index 46ec87db1..eac76a33d 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -2472,6 +2472,18 @@ function _system_update_bootstrap_status() {
function _system_rebuild_theme_data() {
// Find themes
$themes = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', 'themes');
+ // Allow modules to add further themes.
+ if ($module_themes = module_invoke_all('system_theme_info')) {
+ foreach ($module_themes as $name => $uri) {
+ // @see file_scan_directory()
+ $themes[$name] = (object) array(
+ 'uri' => $uri,
+ 'filename' => pathinfo($uri, PATHINFO_FILENAME),
+ 'name' => $name,
+ );
+ }
+ }
+
// Find theme engines
$engines = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.engine$/', 'themes/engines');
diff --git a/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info b/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info
new file mode 100644
index 000000000..9718784f6
--- /dev/null
+++ b/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info
@@ -0,0 +1,4 @@
+name = Update test base theme
+description = Test theme which acts as a base theme for other test subthemes.
+core = 7.x
+hidden = TRUE
diff --git a/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info b/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info
new file mode 100644
index 000000000..6ca42f456
--- /dev/null
+++ b/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info
@@ -0,0 +1,5 @@
+name = Update test subtheme
+description = Test theme which uses update_test_basetheme as the base theme.
+core = 7.x
+base theme = update_test_basetheme
+hidden = TRUE
diff --git a/modules/update/tests/update_test.module b/modules/update/tests/update_test.module
index 4acb6ef83..e7ee43eec 100644
--- a/modules/update/tests/update_test.module
+++ b/modules/update/tests/update_test.module
@@ -1,6 +1,15 @@
<?php
/**
+ * Implements hook_system_theme_info().
+ */
+function update_test_system_theme_info() {
+ $themes['update_test_basetheme'] = drupal_get_path('module', 'update_test') . '/themes/update_test_basetheme/update_test_basetheme.info';
+ $themes['update_test_subtheme'] = drupal_get_path('module', 'update_test') . '/themes/update_test_subtheme/update_test_subtheme.info';
+ return $themes;
+}
+
+/**
* Implements hook_menu().
*/
function update_test_menu() {