summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2009-06-09 21:53:26 (GMT)
committerDries Buytaert2009-06-09 21:53:26 (GMT)
commitcf7371805eba6d5a82da9b88ee9cf8a7b1f4fa4c (patch)
treeefcef7a70bb9e102fff01bd48c0370198dac8969
parent5b6680861b4c211ee0df48e982e134d5d54f9a50 (diff)
- Patch #336475 by kscheirer, Senpai, j.somers: added some tests for theme_table() and stick table headers.
-rw-r--r--modules/simpletest/tests/theme.test43
1 files changed, 42 insertions, 1 deletions
diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test
index a2243ce..a6b2e8c 100644
--- a/modules/simpletest/tests/theme.test
+++ b/modules/simpletest/tests/theme.test
@@ -7,7 +7,7 @@
*/
/**
- * Unit tests for the theme API.
+ * Unit tests for the Theme API.
*/
class TemplateUnitTest extends DrupalWebTestCase {
public static function getInfo() {
@@ -50,5 +50,46 @@ class TemplateUnitTest extends DrupalWebTestCase {
$suggestions = array("page\0");
$this->assertEqual(drupal_discover_template(array('themes/garland'), $suggestions), 'themes/garland/page.tpl.php', t('Unsafe template suggestion fixed'));
}
+}
+/**
+ * Unit tests for theme_table().
+ */
+class ThemeTableUnitTest extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => t('Theme Table'),
+ 'description' => t('Tests built-in theme functions.'),
+ 'group' => t('Theme'),
+ );
+ }
+
+ /**
+ * Tableheader.js provides 'sticky' table headers, and is included by default.
+ */
+ function testThemeTableStickyHeaders() {
+ $header = array('one', 'two', 'three');
+ $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
+ $this->content = theme('table', $header, $rows);
+ $js = drupal_add_js();
+ $this->assertTrue(isset($js['misc/tableheader.js']), t('tableheader.js was included when $sticky = TRUE.'));
+ $this->assertRaw('sticky-enabled', t('Table has a class of sticky-enabled when $sticky = TRUE.'));
+ drupal_static_reset('drupal_add_js');
+ }
+
+ /**
+ * If $sticky is FALSE, no tableheader.js should be included.
+ */
+ function testThemeTableNoStickyHeaders() {
+ $header = array('one', 'two', 'three');
+ $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
+ $attributes = array();
+ $caption = NULL;
+ $colgroups = array();
+ $this->content = theme('table', $header, $rows, $attributes, $caption, $colgroups, FALSE);
+ $js = drupal_add_js();
+ $this->assertFalse(isset($js['misc/tableheader.js']), t('tableheader.js was not included because $sticky = FALSE.'));
+ $this->assertNoRaw('sticky-enabled', t('Table does not have a class of sticky-enabled because $sticky = FALSE.'));
+ drupal_static_reset('drupal_add_js');
+ }
}