public function RecursionProtectionTest::testCircularEmbedding in Entity Embed 8
Tests circular embedding.
File
- tests/
src/ Functional/ RecursionProtectionTest.php, line 42
Class
- RecursionProtectionTest
- Tests recursive rendering protection.
Namespace
Drupal\Tests\entity_embed\FunctionalCode
public function testCircularEmbedding() {
$node1 = $this
->drupalCreateNode([
'type' => 'article',
'title' => "Grandpa",
'body' => [
'value' => 'temp',
'format' => 'custom_format',
],
]);
$node1
->save();
$node2 = $this
->drupalCreateNode([
'type' => 'article',
'title' => "Son",
'body' => [
'value' => 'temp',
'format' => 'custom_format',
],
]);
$node2
->save();
$content = '<div class="node-2-embed">Embedded Son</div> <drupal-entity data-entity-type="node" data-entity-uuid="' . $node2
->uuid() . '" data-view-mode="full"></drupal-entity>';
$node1
->set('body', [
'value' => $content,
'format' => 'custom_format',
]);
$node1
->save();
$content = '<div class="node-1-embed">Embedded Son who is own grandpa</div> <drupal-entity data-entity-type="node" data-entity-uuid="' . $node1
->uuid() . '" data-view-mode="full"></drupal-entity>';
$node2
->set('body', [
'value' => $content,
'format' => 'custom_format',
]);
$node2
->save();
$this
->drupalGet('node/' . $node1
->id());
$page = $this
->getSession()
->getPage();
$this
->assertCount(EntityEmbedFilter::RECURSIVE_RENDER_LIMIT, $page
->findAll('xpath', '//div[@class="node-1-embed"]'));
$this
->assertCount(EntityEmbedFilter::RECURSIVE_RENDER_LIMIT + 1, $page
->findAll('xpath', '//div[@class="node-2-embed"]'));
$this
->drupalGet('node/' . $node2
->id());
$page = $this
->getSession()
->getPage();
$this
->assertCount(EntityEmbedFilter::RECURSIVE_RENDER_LIMIT + 1, $page
->findAll('xpath', '//div[@class="node-1-embed"]'));
$this
->assertCount(EntityEmbedFilter::RECURSIVE_RENDER_LIMIT, $page
->findAll('xpath', '//div[@class="node-2-embed"]'));
}