public function EntityEmbedFilterTest::testRecursionProtection in Entity Embed 8
Tests recursive rendering protection.
File
- tests/
src/ Kernel/ EntityEmbedFilterTest.php, line 313
Class
- EntityEmbedFilterTest
- @coversDefaultClass \Drupal\entity_embed\Plugin\Filter\EntityEmbedFilter @group entity_embed
Namespace
Drupal\Tests\entity_embed\KernelCode
public function testRecursionProtection() {
$text = $this
->createEmbedCode([
'data-entity-type' => 'node',
'data-entity-uuid' => static::EMBEDDED_ENTITY_UUID,
'data-view-mode' => 'default',
]);
// Render and verify the presence of the embedded entity 20 times.
for ($i = 0; $i < 20; $i++) {
$this
->applyFilter($text);
$this
->assertCount(1, $this
->cssSelect('div.embedded-entity > [data-entity-embed-test-view-mode="default"]'));
}
// Render a 21st time, this is exceeding the recursion limit. The entity
// embed markup will be stripped.
$this
->applyFilter($text);
$this
->assertEmpty($this
->getRawContent());
}