function TableTest::testThemeTableWithEmptyMessage in Zircon Profile 8
Same name in this branch
- 8 core/modules/system/src/Tests/Theme/TableTest.php \Drupal\system\Tests\Theme\TableTest::testThemeTableWithEmptyMessage()
- 8 core/modules/system/src/Tests/Render/Element/TableTest.php \Drupal\system\Tests\Render\Element\TableTest::testThemeTableWithEmptyMessage()
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Render/Element/TableTest.php \Drupal\system\Tests\Render\Element\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
- core/
modules/ system/ src/ Tests/ Render/ Element/ TableTest.php, line 84 - Contains \Drupal\system\Tests\Render\Element\TableTest.
Class
- TableTest
- Tests built-in table theme functions.
Namespace
Drupal\system\Tests\Render\ElementCode
function testThemeTableWithEmptyMessage() {
$header = array(
'Header 1',
array(
'data' => 'Header 2',
'colspan' => 2,
),
);
$table = array(
'#type' => 'table',
'#header' => $header,
'#rows' => array(),
'#empty' => 'Empty row.',
);
// Enable the Classy theme.
\Drupal::service('theme_handler')
->install([
'classy',
]);
$this
->config('system.theme')
->set('default', 'classy')
->save();
$this
->render($table);
$this
->removeWhiteSpace();
$this
->assertRaw('<thead><tr><th>Header 1</th><th colspan="2">Header 2</th></tr>', 'Table header found.');
$this
->assertRaw('<tr class="odd"><td colspan="3" class="empty message">Empty row.</td>', 'Colspan on #empty row found.');
}