You are here

public function MigrationPluginManagerTest::testDependencyBuilding in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/MigrationPluginManagerTest.php \Drupal\Tests\migrate\Unit\MigrationPluginManagerTest::testDependencyBuilding()

Tests building dependencies for multiple migrations.

@dataProvider dependencyProvider

File

core/modules/migrate/tests/src/Unit/MigrationPluginManagerTest.php, line 40

Class

MigrationPluginManagerTest
@coversDefaultClass \Drupal\migrate\Plugin\MigrationPluginManager @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

public function testDependencyBuilding($migrations_data, $result_ids) {
  $migrations = [];
  foreach ($migrations_data as $migration_id => $migration_data) {
    $migrations[$migration_id] = new TestMigrationMock($migration_id, $migration_data['dependencies']);
  }
  $ordered_migrations = $this->pluginManager
    ->buildDependencyMigration($migrations, []);

  // Verify results.
  $this
    ->assertEquals($result_ids, array_keys($ordered_migrations));
  foreach ($migrations_data as $migration_id => $migration_data) {
    $migration = $migrations[$migration_id];
    $requirements = $migration_data['result_requirements'];
    if (empty($requirements)) {
      $this
        ->assertEquals([], $migration->set);
    }
    else {
      $requirements = array_combine($requirements, $requirements);
      $this
        ->assertCount(1, $migration->set);
      list($set_prop, $set_requirements) = reset($migration->set);
      $this
        ->assertEquals('requirements', $set_prop);
      $this
        ->assertEquals($requirements, $set_requirements);
    }
  }
}