function MigrateTestBase::prepareMigrations

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Kernel/MigrateTestBase.php \Drupal\Tests\migrate\Kernel\MigrateTestBase::prepareMigrations()
  2. 8.9.x core/modules/migrate/tests/src/Kernel/MigrateTestBase.php \Drupal\Tests\migrate\Kernel\MigrateTestBase::prepareMigrations()
  3. 10 core/modules/migrate/tests/src/Kernel/MigrateTestBase.php \Drupal\Tests\migrate\Kernel\MigrateTestBase::prepareMigrations()

Prepare any dependent migrations.

Parameters

array $id_mappings: A list of ID mappings keyed by migration IDs. Each ID mapping is a list of two arrays, the first are source IDs and the second are destination IDs.

1 call to MigrateTestBase::prepareMigrations()
MigrateUploadTest::setUp in core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadTest.php

File

core/modules/migrate/tests/src/Kernel/MigrateTestBase.php, line 139

Class

MigrateTestBase
Creates abstract base class for migration tests.

Namespace

Drupal\Tests\migrate\Kernel

Code

protected function prepareMigrations(array $id_mappings) {
    $manager = $this->container
        ->get('plugin.manager.migration');
    foreach ($id_mappings as $migration_id => $data) {
        foreach ($manager->createInstances($migration_id) as $migration) {
            $id_map = $migration->getIdMap();
            $id_map->setMessage($this);
            $source_ids = $migration->getSourcePlugin()
                ->getIds();
            foreach ($data as $id_mapping) {
                $row = new Row(array_combine(array_keys($source_ids), $id_mapping[0]), $source_ids);
                $id_map->saveIdMapping($row, $id_mapping[1]);
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.