function RenderElementTypesTest::testHtmlTag
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php \Drupal\KernelTests\Core\Render\Element\RenderElementTypesTest::testHtmlTag()
- 8.9.x core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php \Drupal\KernelTests\Core\Render\Element\RenderElementTypesTest::testHtmlTag()
- 10 core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php \Drupal\KernelTests\Core\Render\Element\RenderElementTypesTest::testHtmlTag()
Tests system #type 'html_tag'.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Render/ Element/ RenderElementTypesTest.php, line 79
Class
- RenderElementTypesTest
- Tests the rendered markup of core render element types.
Namespace
Drupal\KernelTests\Core\Render\ElementCode
public function testHtmlTag() : void {
// Test void element.
$this->assertElements([
'#type' => 'html_tag',
'#tag' => 'meta',
'#value' => 'ignored',
'#attributes' => [
'name' => 'description',
'content' => 'Drupal test',
],
], '<meta name="description" content="Drupal test" />' . "\n", "#type 'html_tag', void element renders properly");
// Test non-void element.
$this->assertElements([
'#type' => 'html_tag',
'#tag' => 'section',
'#value' => 'value',
'#attributes' => [
'class' => [
'unicorns',
],
],
], '<section class="unicorns">value</section>' . "\n", "#type 'html_tag', non-void element renders properly");
// Test empty void element tag.
$this->assertElements([
'#type' => 'html_tag',
'#tag' => 'link',
], "<link />\n", "#type 'html_tag' empty void element renders properly");
// Test empty non-void element tag.
$this->assertElements([
'#type' => 'html_tag',
'#tag' => 'section',
], "<section></section>\n", "#type 'html_tag' empty non-void element renders properly");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.