function RenderElementTypesTest::testContainer
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php \Drupal\KernelTests\Core\Render\Element\RenderElementTypesTest::testContainer()
- 10 core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php \Drupal\KernelTests\Core\Render\Element\RenderElementTypesTest::testContainer()
- 11.x core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php \Drupal\KernelTests\Core\Render\Element\RenderElementTypesTest::testContainer()
Tests system #type 'container'.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Render/ Element/ RenderElementTypesTest.php, line 54
Class
- RenderElementTypesTest
- Tests the markup of core render element types passed to drupal_render().
Namespace
Drupal\KernelTests\Core\Render\ElementCode
public function testContainer() {
// Basic container with no attributes.
$this->assertElements([
'#type' => 'container',
'#markup' => 'foo',
], "<div>foo</div>\n", "#type 'container' with no HTML attributes");
// Container with a class.
$this->assertElements([
'#type' => 'container',
'#markup' => 'foo',
'#attributes' => [
'class' => [
'bar',
],
],
], '<div class="bar">foo</div>' . "\n", "#type 'container' with a class HTML attribute");
// Container with children.
$this->assertElements([
'#type' => 'container',
'child' => [
'#markup' => 'foo',
],
], "<div>foo</div>\n", "#type 'container' with child elements");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.