diff options
-rw-r--r-- | includes/theme.inc | 11 | ||||
-rw-r--r-- | modules/simpletest/tests/theme.test | 15 |
2 files changed, 21 insertions, 5 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index 6bfb95c40..fb911426a 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1680,7 +1680,16 @@ function theme_table($variables) { // Add the 'empty' row message if available. if (!count($rows) && $empty) { - $rows[] = array(array('data' => $empty, 'colspan' => count($header), 'class' => array('empty', 'message'))); + $header_count = 0; + foreach ($header as $header_cell) { + if (is_array($header_cell)) { + $header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1; + } + else { + $header_count++; + } + } + $rows[] = array(array('data' => $empty, 'colspan' => $header_count, 'class' => array('empty', 'message'))); } // Format the table header: diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test index 631d69d5b..cb2a39bb0 100644 --- a/modules/simpletest/tests/theme.test +++ b/modules/simpletest/tests/theme.test @@ -110,15 +110,22 @@ class ThemeTableUnitTest extends DrupalWebTestCase { } /** - * Tests that the table header is printed even if there are no rows. And that - * the empty text is displayed correctly. + * Tests that the table header is printed correctly even if there are no rows, + * and that the empty text is displayed correctly. */ function testThemeTableWithEmptyMessage() { - $header = array(t('Header 1'), t('Header 2')); + $header = array( + t('Header 1'), + array( + 'data' => t('Header 2'), + 'colspan' => 2, + ), + ); $this->content = theme('table', array('header' => $header, 'rows' => array(), 'empty' => t('No strings available.'))); - $this->assertRaw('<tr class="odd"><td colspan="2" class="empty message">No strings available.</td>', t('Correct colspan was set on empty message.')); + $this->assertRaw('<tr class="odd"><td colspan="3" class="empty message">No strings available.</td>', t('Correct colspan was set on empty message.')); $this->assertRaw('<thead><tr><th>Header 1</th>', t('Table header was printed.')); } + } /** |