class PlaceholderGeneratorTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Render/PlaceholderGeneratorTest.php \Drupal\Tests\Core\Render\PlaceholderGeneratorTest
@coversDefaultClass \Drupal\Core\Render\PlaceholderGenerator @group Render
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\Core\Render\RendererTestBase
- class \Drupal\Tests\Core\Render\PlaceholderGeneratorTest
- class \Drupal\Tests\Core\Render\RendererTestBase
Expanded class hierarchy of PlaceholderGeneratorTest
File
- core/
tests/ Drupal/ Tests/ Core/ Render/ PlaceholderGeneratorTest.php, line 17 - Contains \Drupal\Tests\Core\Render\PlaceholderGeneratorTest.
Namespace
Drupal\Tests\Core\RenderView source
class PlaceholderGeneratorTest extends RendererTestBase {
/**
* The tested placeholder generator.
*
* @var \Drupal\Core\Render\PlaceholderGenerator
*/
protected $placeholderGenerator;
/**
* @covers ::createPlaceholder
* @dataProvider providerCreatePlaceholderGeneratesValidHtmlMarkup
*
* 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.
*/
public function testCreatePlaceholderGeneratesValidHtmlMarkup(array $element) {
$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);
}
/**
* @return array
*/
public function providerCreatePlaceholderGeneratesValidHtmlMarkup() {
return [
'multiple-arguments' => [
[
'#lazy_builder' => [
'Drupal\\Tests\\Core\\Render\\PlaceholdersTest::callback',
[
'foo',
'bar',
],
],
],
],
'special-character-&' => [
[
'#lazy_builder' => [
'Drupal\\Tests\\Core\\Render\\PlaceholdersTest::callback',
[
'foo&bar',
],
],
],
],
'special-character-"' => [
[
'#lazy_builder' => [
'Drupal\\Tests\\Core\\Render\\PlaceholdersTest::callback',
[
'foo"bar',
],
],
],
],
'special-character-<' => [
[
'#lazy_builder' => [
'Drupal\\Tests\\Core\\Render\\PlaceholdersTest::callback',
[
'foo<bar',
],
],
],
],
'special-character->' => [
[
'#lazy_builder' => [
'Drupal\\Tests\\Core\\Render\\PlaceholdersTest::callback',
[
'foo>bar',
],
],
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PlaceholderGeneratorTest:: |
protected | property |
The tested placeholder generator. Overrides RendererTestBase:: |
|
PlaceholderGeneratorTest:: |
public | function | ||
PlaceholderGeneratorTest:: |
public | function | @covers ::createPlaceholder @dataProvider providerCreatePlaceholderGeneratesValidHtmlMarkup | |
RendererTestBase:: |
protected | property | ||
RendererTestBase:: |
protected | property | ||
RendererTestBase:: |
protected | property | The mocked controller resolver. | |
RendererTestBase:: |
protected | property | The simulated "current" user role, for use in tests with cache contexts. | |
RendererTestBase:: |
protected | property | The mocked element info. | |
RendererTestBase:: |
protected | property | ||
RendererTestBase:: |
protected | property | The tested render cache. | |
RendererTestBase:: |
protected | property | The tested renderer. | |
RendererTestBase:: |
protected | property | The mocked renderer configuration. | |
RendererTestBase:: |
protected | property | ||
RendererTestBase:: |
protected | property | The mocked theme manager. | |
RendererTestBase:: |
protected | function | Asserts a render cache item. | |
RendererTestBase:: |
protected | function | Generates a random context value for the placeholder tests. | |
RendererTestBase:: |
protected | function |
Overrides UnitTestCase:: |
2 |
RendererTestBase:: |
protected | function | Sets up a memory-based render cache back-end. | |
RendererTestBase:: |
protected | function | Sets up a request object on the request stack. | |
RendererTestBase:: |
protected | function | Sets up a render cache back-end that is asserted to be never used. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |