function TableTest::testThemeTableWithEmptyMessage

Tests that the table header is printed correctly even if there are no rows, and that the empty text is displayed correctly.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php, line 57
Definition of Drupal\system\Tests\Theme\TableTest.

Class

TableTest
Unit tests for theme_table().

Namespace

Drupal\system\Tests\Theme

Code

function testThemeTableWithEmptyMessage() {
  $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="3" class="empty message">No strings available.</td>', 'Correct colspan was set on empty message.');
  $this
    ->assertRaw('<thead><tr><th>Header 1</th>', 'Table header was printed.');
}