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()
- 10 core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php \Drupal\KernelTests\Core\Render\Element\RenderElementTypesTest::testHtmlTag()
- 11.x 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 82
Class
- RenderElementTypesTest
- Tests the markup of core render element types passed to drupal_render().
Namespace
Drupal\KernelTests\Core\Render\ElementCode
public function testHtmlTag() {
// 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.