You are here

public function MigrationTest::testCalculateDependencies in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/tests/src/Kernel/Entity/MigrationTest.php \Drupal\Tests\migrate\Kernel\Entity\MigrationTest::testCalculateDependencies()

@covers ::calculateDependencies

File

core/modules/migrate/tests/src/Kernel/Entity/MigrationTest.php, line 29
Contains \Drupal\Tests\migrate\Kernel\Entity\MigrationTest.

Class

MigrationTest
Tests the Migration entity.

Namespace

Drupal\Tests\migrate\Kernel\Entity

Code

public function testCalculateDependencies() {
  $fixture_migrations = [
    'd6_node__article' => 'd6_node',
    'd6_node__page' => 'd6_node',
    'd6_variables' => 'd6_variables',
  ];
  foreach ($fixture_migrations as $id => $template) {
    $values = [
      'id' => $id,
      'template' => $template,
      'source' => [
        'plugin' => 'empty',
      ],
      'destination' => [
        'plugin' => 'null',
      ],
      'migration_tags' => [],
    ];
    Migration::create($values)
      ->save();
  }
  $values = [
    'migration_dependencies' => [
      'required' => [
        'd6_node:*',
        'd6_variables',
      ],
    ],
    'source' => [
      'plugin' => 'empty',
    ],
    'destination' => [
      'plugin' => 'null',
    ],
  ];
  $migration = new Migration($values, 'migration');
  $expected = [
    'migrate.migration.d6_node__article',
    'migrate.migration.d6_node__page',
    'migrate.migration.d6_variables',
  ];
  $migration
    ->calculateDependencies();
  $this
    ->assertEquals($expected, $migration
    ->getDependencies()['config']);
}