summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-11-02 14:57:43 -0500
committerDavid Rothstein <drothstein@gmail.com>2014-11-02 14:57:43 -0500
commitbc7940aa6a876eeaaa301f54747091166f995b09 (patch)
tree77e71ae43f7245f156f4dbbd64e3f07a6a75cb43 /modules/simpletest
parentf68c6ce8495dbdf396676da1e323339b725b0d13 (diff)
downloadbrdo-bc7940aa6a876eeaaa301f54747091166f995b09.tar.gz
brdo-bc7940aa6a876eeaaa301f54747091166f995b09.tar.bz2
Issue #2058761 by kirby14, thedavidmeister: PHP notice when #attributes is not set with #theme_wrappers 'container'.
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/theme.test98
1 files changed, 85 insertions, 13 deletions
diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test
index 328afec44..f1a743e00 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 assertElements($elements) {
+ foreach($elements as $element) {
+ $this->assertIdentical(drupal_render($element['value']), $element['expected'], '"' . $element['name'] . '" input rendered correctly by drupal_render().');
+ }
+ }
+
+ /**
+ * Tests system #type 'container'.
+ */
+ function testContainer() {
+ $elements = array(
+ // Basic container with no attributes.
+ array(
+ 'name' => "#type 'container' with no HTML attributes",
+ 'value' => array(
+ '#type' => 'container',
+ 'child' => array(
+ '#markup' => 'foo',
+ ),
+ ),
+ 'expected' => '<div>foo</div>',
+ ),
+ // Container with a class.
+ array(
+ 'name' => "#type 'container' with a class HTML attribute",
+ 'value' => array(
+ '#type' => 'container',
+ 'child' => array(
+ '#markup' => 'foo',
+ ),
+ '#attributes' => array(
+ 'class' => 'bar',
+ ),
+ ),
+ 'expected' => '<div class="bar">foo</div>',
+ ),
+ );
+
+ $this->assertElements($elements);
+ }
+
+ /**
+ * Tests system #type '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), '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), 'Test title tag generation.');
+ function testHtmlTag() {
+ $elements = array(
+ // Test auto-closure meta tag generation.
+ array(
+ 'name' => "#type 'html_tag' auto-closure meta tag generation",
+ 'value' => array(
+ '#type' => 'html_tag',
+ '#tag' => 'meta',
+ '#attributes' => array(
+ 'name' => 'description',
+ 'content' => 'Drupal test',
+ ),
+ ),
+ 'expected' => '<meta name="description" content="Drupal test" />' . "\n",
+ ),
+ // Test title tag generation.
+ array(
+ 'name' => "#type 'html_tag' title tag generation",
+ 'value' => array(
+ '#type' => 'html_tag',
+ '#tag' => 'title',
+ '#value' => 'title test',
+ ),
+ 'expected' => '<title>title test</title>' . "\n",
+ ),
+ );
+
+ $this->assertElements($elements);
}
}