You are here

public function DrupalMediaEmbedCollectorTest::testExtractEmbeddedMediaEntities in Dependency Calculation 8

Test dependency calculation.

Checks the node's dependencies contains embedded media entities.

@dataProvider providerTestExtractEmbeddedMediaEntities

Parameters

array $embed_attributes: Attributes to add for the embedded media entity.

File

tests/src/Kernel/EventSubscriber/DependencyCollector/DrupalMediaEmbedCollectorTest.php, line 87

Class

DrupalMediaEmbedCollectorTest
Class DrupalMediaEmbedCollectorTest.

Namespace

Drupal\Tests\depcalc\Kernel\EventSubscriber\DependencyCollector

Code

public function testExtractEmbeddedMediaEntities(array $embed_attributes) {
  $embed_code = '';
  foreach ($embed_attributes as $embed_attribute) {
    $embed_code .= $this
      ->createEmbedCode($embed_attribute);
  }
  $node = $this
    ->createNode([
    'body' => [
      [
        'value' => $embed_code,
        'format' => filter_default_format(),
      ],
    ],
  ]);
  try {
    $wrapper = new DependentEntityWrapper($node);
  } catch (\Exception $exception) {
    $this
      ->markTestIncomplete($exception
      ->getMessage());
  }
  $dependencies = $this->calculator
    ->calculateDependencies($wrapper, new DependencyStack());
  foreach ($embed_attributes as $embed_attribute) {
    $this
      ->assertArrayHasKey($embed_attribute['data-entity-uuid'], $dependencies);
  }
}