.../lib/Drupal/system/Tests/Theme/ThemeTest.php | 22 ++++++++++++++++++++ .../templates/theme-test-render-element.tpl.php | 1 + .../tests/modules/theme_test/theme_test.module | 10 +++++++++ 3 files changed, 33 insertions(+) diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php index 20ccc2b..cdf5d7b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php @@ -36,6 +36,28 @@ function setUp() { } /** + * Test attribute merging. + * + * Render arrays that use a render element and templates (and hence call + * template_preprocess()) must ensure the attributes at different occassions + * are all merged correctly: + * - $variables['attributes'] as passed in to theme() + * - the render element's #attributes + * - any attributes set in the template's preprocessing function + */ + function testAttributeMerging() { + $output = theme('theme_test_render_element', array( + 'elements' => array( + '#attributes' => array('data-foo' => 'bar'), + ), + 'attributes' => array( + 'id' => 'bazinga', + ), + )); + $this->assertIdentical($output, '
' . "\n"); + } + + /** * Test function theme_get_suggestions() for SA-CORE-2009-003. */ function testThemeSuggestions() { diff --git a/core/modules/system/tests/modules/theme_test/templates/theme-test-render-element.tpl.php b/core/modules/system/tests/modules/theme_test/templates/theme-test-render-element.tpl.php new file mode 100644 index 0000000..f301d31 --- /dev/null +++ b/core/modules/system/tests/modules/theme_test/templates/theme-test-render-element.tpl.php @@ -0,0 +1 @@ +