Commit 6d1c15fc authored by Dries's avatar Dries
Browse files

- Patch #952772 by oriol_e9g, mdupont, bleen18, idflood: theme_html_tag()...

- Patch #952772 by oriol_e9g, mdupont, bleen18, idflood: theme_html_tag() optional value not really optional.
parent c8302d62
......@@ -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'];
}
......
......@@ -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.'));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment