diff options
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/tests/common.test | 22 | ||||
-rw-r--r-- | modules/simpletest/tests/common_test.info | 8 | ||||
-rw-r--r-- | modules/simpletest/tests/common_test.module | 25 |
3 files changed, 55 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 905fe7cd0..538fb1b2a 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -587,6 +587,10 @@ class DrupalRenderUnitTestCase extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp('common_test'); + } + /** * Test sorting by weight. */ @@ -637,6 +641,24 @@ class DrupalRenderUnitTestCase extends DrupalWebTestCase { // The elements should appear in output in the same order as the array. $this->assertTrue(strpos($output, $second) < strpos($output, $first), t('Elements were not sorted.')); } + + /** + * Test passing arguments to the theme function. + */ + function testDrupalRenderThemeArguments() { + $element = array( + '#theme' => 'common_test_foo', + ); + // Test that defaults work. + $this->assertEqual(drupal_render($element), 'foobar', 'Defaults work'); + dd(drupal_render($e), 'defaults'); $element = array( + '#theme' => 'common_test_foo', + '#foo' => $this->randomName(), + '#bar' => $this->randomName(), + ); + // Test that passing arguments to the theme function works. + $this->assertEqual(drupal_render($element), $element['#foo'] . $element['#bar'], 'Passing arguments to theme functions works'); + } } /** diff --git a/modules/simpletest/tests/common_test.info b/modules/simpletest/tests/common_test.info new file mode 100644 index 000000000..81a15472a --- /dev/null +++ b/modules/simpletest/tests/common_test.info @@ -0,0 +1,8 @@ +; $Id$ +name = "Common Test" +description = "Support module for Common tests." +package = Testing +version = VERSION +core = 7.x +files[] = common_test.module +hidden = TRUE diff --git a/modules/simpletest/tests/common_test.module b/modules/simpletest/tests/common_test.module new file mode 100644 index 000000000..71d384d10 --- /dev/null +++ b/modules/simpletest/tests/common_test.module @@ -0,0 +1,25 @@ +<?php +// $Id$ + +/** + * @file + * Helper module for the Common tests. + */ + +/** + * Implement hook_theme(). + */ +function common_test_theme() { + return array( + 'common_test_foo' => array( + 'arguments' => array('foo' => 'foo', 'bar' => 'bar'), + ), + ); +} + +/** + * Theme function for testing drupal_render() theming. + */ +function theme_common_test_foo($foo, $bar) { + return $foo . $bar; +} |