function MediaEmbedFilterTest::testRecursionProtection
Tests recursive rendering protection.
File
- 
              core/
modules/ media/ tests/ src/ Kernel/ MediaEmbedFilterTest.php, line 375  
Class
- MediaEmbedFilterTest
 - @coversDefaultClass \Drupal\media\Plugin\Filter\MediaEmbed[[api-linebreak]] @group media
 
Namespace
Drupal\Tests\media\KernelCode
public function testRecursionProtection() {
  $text = $this->createEmbedCode([
    'data-entity-type' => 'media',
    'data-entity-uuid' => static::EMBEDDED_ENTITY_UUID,
  ]);
  // 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[data-media-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());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.