You are here

protected function EntityEmbedFilterTestBase::createEmbedCode in Entity Embed 8

Gets an embed code with given attributes.

Parameters

array $attributes: The attributes to add.

Return value

string A string containing a drupal-entity dom element.

See also

assertEntityEmbedFilterHasRun()

14 calls to EntityEmbedFilterTestBase::createEmbedCode()
EntityEmbedFilterDisabledIntegrationsTest::testDisabledIntegrations in tests/src/Kernel/EntityEmbedFilterDisabledIntegrationsTest.php
@covers \Drupal\entity_embed\Plugin\entity_embed\EntityEmbedDisplay\EntityReferenceFieldFormatter::disableContextualLinks @covers \Drupal\entity_embed\Plugin\entity_embed\EntityEmbedDisplay\EntityReferenceFieldFormatter::disableQuickEdit @dataProvider…
EntityEmbedFilterLegacyTest::testEntityEmbedDisplayDefaultBackwardsCompatibility in tests/src/Kernel/EntityEmbedFilterLegacyTest.php
Tests BC for `data-entity-embed-display="default"`.
EntityEmbedFilterLegacyTest::testEntityEmbedSettingsBackwardsCompatibility in tests/src/Kernel/EntityEmbedFilterLegacyTest.php
Tests BC for `data-entity-embed-display-settings`'s predecessor.
EntityEmbedFilterLegacyTest::testEntityIdBackwardsCompatibility in tests/src/Kernel/EntityEmbedFilterLegacyTest.php
Tests BC for `data-entity-uuid`'s predecessor, `data-entity-id`.
EntityEmbedFilterLegacyTest::testEntityIdIgnoredIfEntityUuidPresent in tests/src/Kernel/EntityEmbedFilterLegacyTest.php
Verifies `data-entity-id` is ignored when `data-entity-uuid` is present.

... See full list

File

tests/src/Kernel/EntityEmbedFilterTestBase.php, line 99

Class

EntityEmbedFilterTestBase
Base class for Entity Embed filter tests.

Namespace

Drupal\Tests\entity_embed\Kernel

Code

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