function MediaEmbedFilterTestBase::createEmbedCode

Same name in other branches
  1. 8.9.x core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTestBase::createEmbedCode()
  2. 10 core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTestBase::createEmbedCode()
  3. 11.x core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTestBase::createEmbedCode()

Gets an embed code with given attributes.

Parameters

array $attributes: The attributes to add.

Return value

string A string containing a drupal-media DOM element.

See also

assertEntityEmbedFilterHasRun()

10 calls to MediaEmbedFilterTestBase::createEmbedCode()
MediaEmbedFilterDisabledIntegrationsTest::testDisabledIntegrations in core/modules/media/tests/src/Kernel/MediaEmbedFilterDisabledIntegrationsTest.php
@covers ::renderMedia @covers ::disableContextualLinks
MediaEmbedFilterDisabledIntegrationsTest::testDisabledIntegrations in core/modules/quickedit/tests/src/Kernel/MediaEmbedFilterDisabledIntegrationsTest.php
@covers ::renderMedia @covers ::disableContextualLinks
MediaEmbedFilterTest::testAccessUnpublished in core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php
Tests that entity access is respected by embedding an unpublished entity.
MediaEmbedFilterTest::testBasics in core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php
Ensures media entities are rendered correctly.
MediaEmbedFilterTest::testFilterIntegration in core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php
@covers \Drupal\filter\Plugin\Filter\FilterAlign @covers \Drupal\filter\Plugin\Filter\FilterCaption @dataProvider providerFilterIntegration

... See full list

File

core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php, line 155

Class

MediaEmbedFilterTestBase
Base class for Media Embed filter tests.

Namespace

Drupal\Tests\media\Kernel

Code

protected function createEmbedCode(array $attributes) {
    $dom = Html::load('<drupal-media>This placeholder should not be rendered.</drupal-media>');
    $xpath = new \DOMXPath($dom);
    $drupal_entity = $xpath->query('//drupal-media')[0];
    foreach ($attributes as $attribute => $value) {
        $drupal_entity->setAttribute($attribute, $value);
    }
    return Html::serialize($dom);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.