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()
- 8.9.x 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()
Tests system #type 'container'.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Render/ Element/ RenderElementTypesTest.php, line 51
Class
- RenderElementTypesTest
- Tests the rendered markup of core render element types.
Namespace
Drupal\KernelTests\Core\Render\ElementCode
public function testContainer() : void {
// 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.