function PlaceholderGeneratorTest::testCreatePlaceholderGeneratesValidHtmlMarkup
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Render/PlaceholderGeneratorTest.php \Drupal\Tests\Core\Render\PlaceholderGeneratorTest::testCreatePlaceholderGeneratesValidHtmlMarkup()
- 8.9.x core/tests/Drupal/Tests/Core/Render/PlaceholderGeneratorTest.php \Drupal\Tests\Core\Render\PlaceholderGeneratorTest::testCreatePlaceholderGeneratesValidHtmlMarkup()
- 10 core/tests/Drupal/Tests/Core/Render/PlaceholderGeneratorTest.php \Drupal\Tests\Core\Render\PlaceholderGeneratorTest::testCreatePlaceholderGeneratesValidHtmlMarkup()
Ensure that the generated placeholder markup is valid.
If it is not, then simply using DOMDocument on HTML that contains placeholders may modify the placeholders' markup, which would make it impossible to replace the placeholders: the placeholder markup in #attached versus that in the HTML processed by DOMDocument would no longer match.
@covers ::createPlaceholder @dataProvider providerCreatePlaceholderGeneratesValidHtmlMarkup
File
-
core/
tests/ Drupal/ Tests/ Core/ Render/ PlaceholderGeneratorTest.php, line 35
Class
- PlaceholderGeneratorTest
- @coversDefaultClass \Drupal\Core\Render\PlaceholderGenerator @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testCreatePlaceholderGeneratesValidHtmlMarkup(array $element) : void {
$build = $this->placeholderGenerator
->createPlaceholder($element);
$original_placeholder_markup = (string) $build['#markup'];
$processed_placeholder_markup = Html::serialize(Html::load($build['#markup']));
$this->assertEquals($original_placeholder_markup, $processed_placeholder_markup);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.