You are here

public function EmbeddedImagesCollectorTest::testDependenciesCalculationWithoutImagesCollector in Dependency Calculation 8

Checks EmbeddedImagesCollector absence.

Checks that without EmbeddedImagesCollector uploaded images isn't node dependencies.

@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 119

Class

EmbeddedImagesCollectorTest
Class EmbeddedImagesCollectorTest.

Namespace

Drupal\Tests\depcalc\Kernel\EventSubscriber\DependencyCollector

Code

public function testDependenciesCalculationWithoutImagesCollector(array $files_ids, array $usages) {
  $mock = $this
    ->getMockBuilder(EmbeddedImagesCollector::class)
    ->disableOriginalConstructor()
    ->getMock();
  \Drupal::getContainer()
    ->set('embedded_images.calculator', $mock);
  $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
      ->assertArrayNotHasKey($uuid, $dependencies);
  }
}