diff --git a/core/modules/system/src/Tests/Render/Element/TableTest.php b/core/modules/system/src/Tests/Render/Element/TableTest.php index 725f339..6297ca4 100644 --- a/core/modules/system/src/Tests/Render/Element/TableTest.php +++ b/core/modules/system/src/Tests/Render/Element/TableTest.php @@ -10,7 +10,7 @@ use Drupal\simpletest\KernelTestBase; /** - * Tests built-in table theme functions. + * Tests built-in table templates. * * @group Theme */ diff --git a/core/modules/system/src/Tests/Render/TypeTableTest.php b/core/modules/system/src/Tests/Render/TypeTableTest.php new file mode 100644 index 0000000..8a97724 --- /dev/null +++ b/core/modules/system/src/Tests/Render/TypeTableTest.php @@ -0,0 +1,64 @@ + 'Type Table', + 'description' => "Tests #type 'table' render functions.", + 'group' => 'Render', + ); + } + + /** + * Tests that #type table rows can be rendered from the #rows property. + */ + public function testRenderTableFromRows() { + $table = array( + '#type' => 'table', + '#rows' => array( + array('Foo', 'Bar', array('data' => array('#markup' => 'Baz'))), + ), + ); + $this->content = drupal_render($table); + $this->assertRaw('FooBarBaz ', 'Table row rendered from #rows property.'); + } + + /** + * Tests that #type table rows can be rendered from sets of render arrays. + */ + public function testRenderTableFromChildren() { + $table = array( + '#type' => 'table', + array( + array('#markup' => 'Foo'), + array('#markup' => 'Bar'), + array('#markup' => 'Baz'), + ), + ); + $this->content = drupal_render($table); + $this->assertRaw('FooBarBaz ', 'Table row rendered from child render elements.'); + } + + /** + * Tests that tablesort functionality can be added to #type table elements. + */ + public function testRenderTableWithTabledrag() { + $this->getUrl('/render-test/type-table-tabledrag'); + $this->assertRaw('Foo 1Bar 1Baz 1 \n Foo 2Bar 2Baz 2 ', 'Table row rendered with tabledrag from child render elements.'); + } + +}