public function MigrationGroupTest::testConfigurationMerge in Migrate Plus 8.2
Same name and namespace in other branches
- 8.5 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 22
Class
- MigrationGroupTest
- Test migration groups.
Namespace
Drupal\Tests\migrate_plus\KernelCode
public function testConfigurationMerge() {
$group_id = 'test_group';
/** @var MigrationGroupInterface $migration_group */
$group_configuration = [
'id' => $group_id,
'shared_configuration' => [
'migration_tags' => [
'Drupal 6',
],
// In migration, so will be overridden.
'source' => [
'constants' => [
'type' => 'image',
// Not in migration, so will be added.
'cardinality' => '1',
],
],
'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',
'migration_tags' => [
'Drupal 7',
],
// Overrides group.
'destination' => [],
'source' => [],
'process' => [],
'migration_dependencies' => [],
]);
$migration
->set('source', [
'plugin' => 'empty',
// Not in group, persists.
'constants' => [
'entity_type' => 'user',
// Not in group, persists.
'cardinality' => '3',
],
]);
$migration
->save();
$expected_config = [
'migration_group' => $group_id,
'label' => 'Unaffected by the group',
'migration_tags' => [
'Drupal 7',
],
'source' => [
'plugin' => 'empty',
'constants' => [
'entity_type' => 'user',
'type' => 'image',
'cardinality' => '3',
],
],
'destination' => [
'plugin' => 'field_storage_config',
],
];
/** @var \Drupal\migrate\Plugin\MigrationInterface $loaded_migration */
$loaded_migration = $this->container
->get('plugin.manager.config_entity_migration')
->createInstance('specific_migration');
foreach ($expected_config as $key => $expected_value) {
$actual_value = $loaded_migration
->get($key);
$this
->assertEquals($expected_value, $actual_value);
}
}