summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/theme.inc5
-rw-r--r--modules/simpletest/tests/theme.test26
2 files changed, 29 insertions, 2 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index 6c2b64069..49865cfe0 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1902,11 +1902,12 @@ function theme_feed_icon($variables) {
*/
function theme_html_tag($variables) {
$element = $variables['element'];
+ $attributes = isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '';
if (!isset($element['#value'])) {
- return '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . " />\n";
+ return '<' . $element['#tag'] . $attributes . " />\n";
}
else {
- $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>';
+ $output = '<' . $element['#tag'] . $attributes . '>';
if (isset($element['#value_prefix'])) {
$output .= $element['#value_prefix'];
}
diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test
index f1e1bd58b..53557e361 100644
--- a/modules/simpletest/tests/theme.test
+++ b/modules/simpletest/tests/theme.test
@@ -354,3 +354,29 @@ class ThemeFastTestCase extends DrupalWebTestCase {
$this->assertText('registry not initialized', t('The registry was not initialized'));
}
}
+
+/**
+ * Unit tests for theme_html_tag().
+ */
+class ThemeHtmlTag extends DrupalUnitTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Theme HTML Tag',
+ 'description' => 'Tests theme_html_tag() built-in theme functions.',
+ 'group' => 'Theme',
+ );
+ }
+
+ /**
+ * Test function theme_html_tag()
+ */
+ function testThemeHtmlTag() {
+ // Test auto-closure meta tag generation
+ $tag['element'] = array('#tag' => 'meta', '#attributes' => array('name' => 'description', 'content' => 'Drupal test'));
+ $this->assertEqual('<meta name="description" content="Drupal test" />'."\n", theme_html_tag($tag), t('Test auto-closure meta tag generation.'));
+
+ // Test title tag generation
+ $tag['element'] = array('#tag' => 'title', '#value' => 'title test');
+ $this->assertEqual('<title>title test</title>'."\n", theme_html_tag($tag), t('Test title tag generation.'));
+ }
+}