diff --git a/includes/form.inc b/includes/form.inc index b139e43f751..da1caa819f4 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -3311,6 +3311,8 @@ function form_process_container($element, &$form_state) { */ function theme_container($variables) { $element = $variables['element']; + // Ensure #attributes is set. + $element += array('#attributes' => array()); // Special handling for form elements. if (isset($element['#array_parents'])) { diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test index 328afec44dd..f1a743e00c0 100644 --- a/modules/simpletest/tests/theme.test +++ b/modules/simpletest/tests/theme.test @@ -425,28 +425,100 @@ class ThemeFastTestCase extends DrupalWebTestCase { } /** - * Unit tests for theme_html_tag(). + * Tests the markup of core render element types passed to drupal_render(). */ -class ThemeHtmlTag extends DrupalUnitTestCase { +class RenderElementTypesTestCase extends DrupalWebTestCase { public static function getInfo() { return array( - 'name' => 'Theme HTML Tag', - 'description' => 'Tests theme_html_tag() built-in theme functions.', + 'name' => 'Render element types', + 'description' => 'Tests the markup of core render element types passed to drupal_render().', 'group' => 'Theme', ); } /** - * Test function theme_html_tag() + * Asserts that an array of elements is rendered properly. + * + * @param array $elements + * An array of associative arrays describing render elements and their + * expected markup. Each item in $elements must contain the following: + * - 'name': This human readable description will be displayed on the test + * results page. + * - 'value': This is the render element to test. + * - 'expected': This is the expected markup for the element in 'value'. */ - function testThemeHtmlTag() { - // Test auto-closure meta tag generation - $tag['element'] = array('#tag' => 'meta', '#attributes' => array('name' => 'description', 'content' => 'Drupal test')); - $this->assertEqual(''."\n", theme_html_tag($tag), 'Test auto-closure meta tag generation.'); + function assertElements($elements) { + foreach($elements as $element) { + $this->assertIdentical(drupal_render($element['value']), $element['expected'], '"' . $element['name'] . '" input rendered correctly by drupal_render().'); + } + } - // Test title tag generation - $tag['element'] = array('#tag' => 'title', '#value' => 'title test'); - $this->assertEqual('