diff options
-rw-r--r-- | includes/theme.inc | 7 | ||||
-rw-r--r-- | includes/unicode.inc | 2 | ||||
-rw-r--r-- | modules/simpletest/tests/theme.test | 16 | ||||
-rw-r--r-- | modules/simpletest/tests/theme_test.inc | 15 | ||||
-rw-r--r-- | modules/simpletest/tests/theme_test.module | 16 | ||||
-rw-r--r-- | modules/simpletest/tests/themes/test_theme/template.php | 6 |
6 files changed, 42 insertions, 20 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index da4200e56..0712f8797 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -991,6 +991,13 @@ function theme($hook, $variables = array()) { if (isset($info['base hook'])) { $base_hook = $info['base hook']; $base_hook_info = $hooks[$base_hook]; + // Include files required by the base hook, since its variable processors + // might reside there. + if (!empty($base_hook_info['includes'])) { + foreach ($base_hook_info['includes'] as $include_file) { + include_once DRUPAL_ROOT . '/' . $include_file; + } + } if (isset($base_hook_info['preprocess functions']) || isset($base_hook_info['process functions'])) { $variables['theme_hook_suggestion'] = $hook; $hook = $base_hook; diff --git a/includes/unicode.inc b/includes/unicode.inc index 9dde2ca70..cd9cd9bf0 100644 --- a/includes/unicode.inc +++ b/includes/unicode.inc @@ -73,7 +73,7 @@ define('PREG_CLASS_UNICODE_WORD_BOUNDARY', '\x{A836}-\x{A839}\x{A874}-\x{A877}\x{A8CE}-\x{A8CF}\x{A8F8}-\x{A8FA}' . '\x{A92E}-\x{A92F}\x{A95F}\x{A9C1}-\x{A9CD}\x{A9DE}-\x{A9DF}' . '\x{AA5C}-\x{AA5F}\x{AA77}-\x{AA79}\x{AADE}-\x{AADF}\x{ABEB}' . - '\x{D800}-\x{F8FF}\x{FB29}\x{FD3E}-\x{FD3F}\x{FDFC}-\x{FDFD}' . + '\x{E000}-\x{F8FF}\x{FB29}\x{FD3E}-\x{FD3F}\x{FDFC}-\x{FDFD}' . '\x{FE10}-\x{FE19}\x{FE30}-\x{FE6B}\x{FEFF}-\x{FF0F}\x{FF1A}-\x{FF20}' . '\x{FF3B}-\x{FF40}\x{FF5B}-\x{FF65}\x{FFE0}-\x{FFFD}'); diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test index af1141124..19775a7f8 100644 --- a/modules/simpletest/tests/theme.test +++ b/modules/simpletest/tests/theme.test @@ -52,11 +52,19 @@ class ThemeUnitTest extends DrupalWebTestCase { } /** - * Preprocess functions for the base hook should run even for suggestion implementations. - */ + * Ensures preprocess functions run even for suggestion implementations. + * + * The theme hook used by this test has its base preprocess function in a + * separate file, so this test also ensures that that file is correctly loaded + * when needed. + */ function testPreprocessForSuggestions() { - $this->drupalGet('theme-test/suggestion'); - $this->assertText('test_theme_breadcrumb__suggestion: 1', t('Theme hook suggestion ran with data available from a preprocess function for the base hook.')); + // Test with both an unprimed and primed theme registry. + drupal_theme_rebuild(); + for ($i = 0; $i < 2; $i++) { + $this->drupalGet('theme-test/suggestion'); + $this->assertText('Theme hook implementor=test_theme_theme_test__suggestion(). Foo=template_preprocess_theme_test', 'Theme hook suggestion ran with data available from a preprocess function for the base hook.'); + } } /** diff --git a/modules/simpletest/tests/theme_test.inc b/modules/simpletest/tests/theme_test.inc new file mode 100644 index 000000000..6cde68384 --- /dev/null +++ b/modules/simpletest/tests/theme_test.inc @@ -0,0 +1,15 @@ +<?php + +/** + * Returns HTML for the 'theme_test' theme hook used by tests. + */ +function theme_theme_test($variables) { + return 'Theme hook implementor=theme_theme_test(). Foo=' . $variables['foo']; +} + +/** + * Preprocesses variables for theme_theme_test(). + */ +function template_preprocess_theme_test(&$variables) { + $variables['foo'] = 'template_preprocess_theme_test'; +} diff --git a/modules/simpletest/tests/theme_test.module b/modules/simpletest/tests/theme_test.module index 48e2e83c6..cce7b8093 100644 --- a/modules/simpletest/tests/theme_test.module +++ b/modules/simpletest/tests/theme_test.module @@ -4,13 +4,16 @@ * Implements hook_theme(). */ function theme_test_theme($existing, $type, $theme, $path) { + $items['theme_test'] = array( + 'file' => 'theme_test.inc', + 'variables' => array('foo' => ''), + ); $items['theme_test_template_test'] = array( 'template' => 'theme_test.template_test', ); $items['theme_test_template_test_2'] = array( 'template' => 'theme_test.template_test', ); - return $items; } @@ -115,14 +118,5 @@ function _theme_test_alter() { * Page callback, calls a theme hook suggestion. */ function _theme_test_suggestion() { - return theme(array('breadcrumb__suggestion', 'breadcrumb'), array()); -} - -/** - * Implements hook_preprocess_breadcrumb(). - * - * Set a variable that can later be tested to see if this function ran. - */ -function theme_test_preprocess_breadcrumb(&$variables) { - $variables['theme_test_preprocess_breadcrumb'] = 1; + return theme(array('theme_test__suggestion', 'theme_test'), array()); } diff --git a/modules/simpletest/tests/themes/test_theme/template.php b/modules/simpletest/tests/themes/test_theme/template.php index ef8118a6d..8275818e4 100644 --- a/modules/simpletest/tests/themes/test_theme/template.php +++ b/modules/simpletest/tests/themes/test_theme/template.php @@ -3,10 +3,8 @@ /** * 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']; +function test_theme_theme_test__suggestion($variables) { + return 'Theme hook implementor=test_theme_theme_test__suggestion(). Foo=' . $variables['foo']; } /** |