public function TableTest::testThemeTableStickyHeaders in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php \Drupal\KernelTests\Core\Render\Element\TableTest::testThemeTableStickyHeaders()
- 10 core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php \Drupal\KernelTests\Core\Render\Element\TableTest::testThemeTableStickyHeaders()
Tableheader.js provides 'sticky' table headers, and is included by default.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Render/ Element/ TableTest.php, line 24
Class
- TableTest
- Tests built-in table theme functions.
Namespace
Drupal\KernelTests\Core\Render\ElementCode
public function testThemeTableStickyHeaders() {
$header = [
'one',
'two',
'three',
];
$rows = [
[
1,
2,
3,
],
[
4,
5,
6,
],
[
7,
8,
9,
],
];
$table = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#sticky' => TRUE,
];
$this
->render($table);
// Make sure tableheader.js was attached.
$tableheader = $this
->xpath("//script[contains(@src, 'tableheader.js')]");
$this
->assertCount(1, $tableheader);
$this
->assertRaw('sticky-enabled');
}