public function DrushWithMigrateUpgradeFromFileTest::assertImageMediaMigrations in Media Migration 8
Tests image file to media migrations.
Parameters
\Drupal\migrate_plus\Entity\MigrationInterface[] $media_migrations: Array of migration entities tagged with MediaMigration::MIGRATION_TAG.
1 call to DrushWithMigrateUpgradeFromFileTest::assertImageMediaMigrations()
- DrushWithMigrateUpgradeFromFileTest::testMigrationWithDrush in tests/
src/ Functional/ DrushWithMigrateUpgradeFromFileTest.php - Tests migrations with Migrate Upgrade, Drush and Migrate Tools.
File
- tests/
src/ Functional/ DrushWithMigrateUpgradeFromFileTest.php, line 1264
Class
- DrushWithMigrateUpgradeFromFileTest
- Tests Migrate Upgrade compatibility and verifies usage steps of README.
Namespace
Drupal\Tests\media_migration\FunctionalCode
public function assertImageMediaMigrations(array $media_migrations) {
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_type_image',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_plain_type',
'constants' => [
'status' => TRUE,
],
'mimes' => 'image',
'schemes' => 'public',
'destination_media_type_id' => 'image',
],
'process' => [
'status' => [
[
'plugin' => 'get',
'source' => 'constants/status',
],
],
'id' => [
[
'plugin' => 'get',
'source' => 'bundle',
],
],
'label' => [
[
'plugin' => 'get',
'source' => 'bundle_label',
],
],
'source' => [
[
'plugin' => 'get',
'source' => 'source_plugin_id',
],
],
'source_configuration/source_field' => [
[
'plugin' => 'get',
'source' => 'source_field_name',
],
],
],
'destination' => [
'plugin' => 'entity:media_type',
],
'migration_dependencies' => [
'required' => [],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_type_image']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_source_field_image',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_plain_source_field_storage',
'constants' => [
'entity_type_id' => 'media',
'status' => TRUE,
'langcode' => 'und',
'cardinality' => 1,
],
'mimes' => 'image',
'schemes' => 'public',
'destination_media_type_id' => 'image',
],
'process' => [
'status' => [
[
'plugin' => 'get',
'source' => 'constants/status',
],
],
'field_name' => [
[
'plugin' => 'get',
'source' => 'source_field_name',
],
],
'langcode' => [
[
'plugin' => 'get',
'source' => 'constants/langcode',
],
],
'entity_type' => [
[
'plugin' => 'get',
'source' => 'constants/entity_type_id',
],
],
'type' => [
[
'plugin' => 'get',
'source' => 'field_type',
],
],
'cardinality' => [
[
'plugin' => 'get',
'source' => 'constants/cardinality',
],
],
'settings' => [
[
'plugin' => 'get',
'source' => 'settings',
],
],
],
'destination' => [
'plugin' => 'entity:field_storage_config',
],
'migration_dependencies' => [
'required' => [
'upgrade_d7_file_plain_type_image',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_source_field_image']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_source_field_config_image',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_plain_source_field_instance',
'constants' => [
'entity_type_id' => 'media',
'required' => TRUE,
],
'mimes' => 'image',
'schemes' => 'public',
'destination_media_type_id' => 'image',
],
'process' => [
'label' => [
[
'plugin' => 'get',
'source' => 'source_field_label',
],
],
'field_name' => [
[
'plugin' => 'get',
'source' => 'source_field_name',
],
],
'entity_type' => [
[
'plugin' => 'get',
'source' => 'constants/entity_type_id',
],
],
'required' => [
[
'plugin' => 'get',
'source' => 'constants/required',
],
],
'bundle' => [
[
'plugin' => 'get',
'source' => 'bundle',
],
],
'settings' => [
[
'plugin' => 'get',
'source' => 'settings',
],
],
],
'destination' => [
'plugin' => 'entity:field_config',
],
'migration_dependencies' => [
'required' => [
'upgrade_d7_file_plain_source_field_image',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_source_field_config_image']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_formatter_image',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_plain_field_formatter',
'constants' => [
'entity_type_id' => 'media',
'view_mode' => 'default',
],
'mimes' => 'image',
'schemes' => 'public',
'destination_media_type_id' => 'image',
],
'process' => [
'entity_type' => [
[
'plugin' => 'get',
'source' => 'constants/entity_type_id',
],
],
'bundle' => [
[
'plugin' => 'get',
'source' => 'bundle',
],
],
'view_mode' => [
[
'plugin' => 'get',
'source' => 'constants/view_mode',
],
],
'field_name' => [
[
'plugin' => 'get',
'source' => 'field_name',
],
],
'hidden' => [
[
'plugin' => 'get',
'source' => 'hidden',
],
],
'options' => [
[
'plugin' => 'get',
'source' => 'options',
],
],
],
'destination' => [
'plugin' => 'component_entity_display',
],
'migration_dependencies' => [
'required' => [
'upgrade_d7_file_plain_source_field_config_image',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_formatter_image']));
// Widget settings migration.
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_widget_image',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_plain_field_widget',
'constants' => [
'entity_type_id' => 'media',
'form_mode' => 'default',
],
'mimes' => 'image',
'schemes' => 'public',
'destination_media_type_id' => 'image',
],
'process' => [
'entity_type' => [
[
'plugin' => 'get',
'source' => 'constants/entity_type_id',
],
],
'bundle' => [
[
'plugin' => 'get',
'source' => 'bundle',
],
],
'form_mode' => [
[
'plugin' => 'get',
'source' => 'constants/form_mode',
],
],
'field_name' => [
[
'plugin' => 'get',
'source' => 'source_field_name',
],
],
'options' => [
[
'plugin' => 'get',
'source' => 'options',
],
],
],
'destination' => [
'plugin' => 'component_entity_form_display',
],
'migration_dependencies' => [
'required' => [
'upgrade_d7_file_plain_source_field_config_image',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_widget_image']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_image_public',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Content',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONTENT,
],
'source' => [
'plugin' => 'd7_file_plain',
'mime' => 'image',
'scheme' => 'public',
'destination_media_type_id' => 'image',
],
'process' => [
'uuid' => [
[
'plugin' => 'media_migrate_uuid',
'source' => 'fid',
],
],
'mid' => [
[
'plugin' => 'get',
'source' => 'fid',
],
],
'uid' => [
[
'plugin' => 'migration_lookup',
'source' => 'uid',
'migration' => 'upgrade_d7_user',
],
[
'plugin' => 'default_value',
'default_value' => 1,
],
],
'bundle' => [
[
'plugin' => 'get',
'source' => 'bundle',
],
],
'name' => [
[
'plugin' => 'get',
'source' => 'filename',
],
],
'created' => [
[
'plugin' => 'get',
'source' => 'timestamp',
],
],
'status' => [
[
'plugin' => 'get',
'source' => 'status',
],
],
'field_media_image/target_id' => [
[
'plugin' => 'get',
'source' => 'fid',
],
],
'field_media_image/width' => [
[
'plugin' => 'get',
'source' => 'width',
],
],
'field_media_image/height' => [
[
'plugin' => 'get',
'source' => 'height',
],
],
'thumbnail/target_id' => [
[
'plugin' => 'get',
'source' => 'fid',
],
],
'thumbnail/width' => [
[
'plugin' => 'get',
'source' => 'width',
],
],
'thumbnail/height' => [
[
'plugin' => 'get',
'source' => 'height',
],
],
'thumbnail/alt' => [
[
'plugin' => 'null_coalesce',
'source' => [
'alt',
'description',
],
],
],
'field_media_image/alt' => [
[
'plugin' => 'null_coalesce',
'source' => [
'alt',
'description',
],
],
],
'thumbnail/title' => [
[
'plugin' => 'get',
'source' => 'title',
],
],
'field_media_image/title' => [
[
'plugin' => 'get',
'source' => 'title',
],
],
],
'destination' => [
'plugin' => 'entity:media',
],
'migration_dependencies' => [
'required' => [
'upgrade_d7_file_plain_type_image',
'upgrade_d7_file_plain_source_field_config_image',
'upgrade_d7_file',
],
'optional' => [
'upgrade_d7_user',
],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_image_public']));
}