You are here

public function MigrationTest::testGetMigrationDependencies in Drupal 9

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

Tests Migration::getMigrationDependencies()

@covers ::getMigrationDependencies

File

core/modules/migrate/tests/src/Kernel/Plugin/MigrationTest.php, line 108

Class

MigrationTest
Tests the migration plugin.

Namespace

Drupal\Tests\migrate\Kernel\Plugin

Code

public function testGetMigrationDependencies() {
  $plugin_manager = \Drupal::service('plugin.manager.migration');
  $plugin_definition = [
    'id' => 'foo',
    'deriver' => 'fooDeriver',
    'process' => [
      'f1' => 'bar',
      'f2' => [
        'plugin' => 'migration',
        'migration' => 'm1',
      ],
      'f3' => [
        'plugin' => 'sub_process',
        'process' => [
          'target_id' => [
            'plugin' => 'migration',
            'migration' => 'm2',
          ],
        ],
      ],
      'f4' => [
        'plugin' => 'migration_lookup',
        'migration' => 'm3',
      ],
      'f5' => [
        'plugin' => 'sub_process',
        'process' => [
          'target_id' => [
            'plugin' => 'migration_lookup',
            'migration' => 'm4',
          ],
        ],
      ],
      'f6' => [
        'plugin' => 'iterator',
        'process' => [
          'target_id' => [
            'plugin' => 'migration_lookup',
            'migration' => 'm5',
          ],
        ],
      ],
      'f7' => [
        'plugin' => 'migration_lookup',
        'migration' => 'foo',
      ],
    ],
  ];
  $migration = $plugin_manager
    ->createStubMigration($plugin_definition);
  $this
    ->assertSame([
    'required' => [],
    'optional' => [
      'm1',
      'm2',
      'm3',
      'm4',
      'm5',
    ],
  ], $migration
    ->getMigrationDependencies());
}