You are here

public function EmbeddedImagesCollectorTest::testDependenciesCalculation in Dependency Calculation 8

Tests dependency calculation.

Checks that node's dependencies contains attached files.

@dataProvider dependenciesCalculationProvider

Parameters

array $files_ids: UUIDs of attached files.

array $usages: Usages map for files.

Throws

\Drupal\Core\Entity\EntityStorageException

File

tests/src/Kernel/EventSubscriber/DependencyCollector/EmbeddedImagesCollectorTest.php, line 85

Class

EmbeddedImagesCollectorTest
Class EmbeddedImagesCollectorTest.

Namespace

Drupal\Tests\depcalc\Kernel\EventSubscriber\DependencyCollector

Code

public function testDependenciesCalculation(array $files_ids, array $usages) {
  $node = $this
    ->createNode();
  foreach ($files_ids as $delta => $uuid) {
    $this
      ->uploadAndAttachFileToNode($uuid, $usages[$delta], $node);
  }
  try {
    $wrapper = new DependentEntityWrapper($node);
  } catch (\Exception $exception) {
    $this
      ->markTestIncomplete($exception
      ->getMessage());
    return;
  }
  $dependencies = $this->calculator
    ->calculateDependencies($wrapper, new DependencyStack());
  foreach ($files_ids as $uuid) {
    $this
      ->assertArrayHasKey($uuid, $dependencies);
  }
}