public function MigrationGroupTest::testConfigurationMerge in Migrate Plus 8.5
Same name and namespace in other branches
- 8.2 tests/src/Kernel/MigrationGroupTest.php \Drupal\Tests\migrate_plus\Kernel\MigrationGroupTest::testConfigurationMerge()
- 8.3 tests/src/Kernel/MigrationGroupTest.php \Drupal\Tests\migrate_plus\Kernel\MigrationGroupTest::testConfigurationMerge()
- 8.4 tests/src/Kernel/MigrationGroupTest.php \Drupal\Tests\migrate_plus\Kernel\MigrationGroupTest::testConfigurationMerge()
Test that group configuration is properly merged into specific migrations.
File
- tests/
src/ Kernel/ MigrationGroupTest.php, line 24
Class
- MigrationGroupTest
- Test migration groups.
Namespace
Drupal\Tests\migrate_plus\KernelCode
public function testConfigurationMerge() : void {
$group_id = 'test_group';
/** @var \Drupal\migrate_plus\Entity\MigrationGroupInterface $migration_group */
$group_configuration = [
'id' => $group_id,
'shared_configuration' => [
// In migration, so will be overridden.
'migration_tags' => [
'Drupal 6',
],
'source' => [
'constants' => [
// Not in migration, so will be added.
'type' => 'image',
// In migration, so will be overridden.
'cardinality' => '1',
],
],
// Not in migration, so will be added.
'destination' => [
'plugin' => 'field_storage_config',
],
],
];
$this->container
->get('entity_type.manager')
->getStorage('migration_group')
->create($group_configuration)
->save();
/** @var \Drupal\migrate_plus\Entity\MigrationInterface $migration */
$migration = $this->container
->get('entity_type.manager')
->getStorage('migration')
->create([
'id' => 'specific_migration',
'load' => [],
'migration_group' => $group_id,
'label' => 'Unaffected by the group',
// Overrides group.
'migration_tags' => [
'Drupal 7',
],
'destination' => [],
'source' => [],
'process' => [],
'migration_dependencies' => [],
]);
$migration
->set('source', [
// Not in group, persists.
'plugin' => 'empty',
'constants' => [
// Not in group, persists.
'entity_type' => 'user',
// Overrides group.
'cardinality' => '3',
],
]);
$migration
->save();
$expected_config = [
'label' => 'Unaffected by the group',
'getMigrationTags' => [
'Drupal 7',
],
'getSourceConfiguration' => [
'plugin' => 'empty',
'constants' => [
'entity_type' => 'user',
'type' => 'image',
'cardinality' => '3',
],
],
'getDestinationConfiguration' => [
'plugin' => 'field_storage_config',
],
];
/** @var \Drupal\migrate_plus\Plugin\MigrationInterface $loaded_migration */
$loaded_migration = $this->container
->get('plugin.manager.migration')
->createInstance('specific_migration');
foreach ($expected_config as $method => $expected_value) {
$actual_value = $loaded_migration
->{$method}();
$this
->assertEquals($expected_value, $actual_value);
}
}