public function DrushWithMigrateUpgradeFromFileTest::assertDocumentMediaMigrations in Media Migration 8
Tests "document" 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::assertDocumentMediaMigrations()
- DrushWithMigrateUpgradeFromFileTest::testMigrationWithDrush in tests/
src/ Functional/ DrushWithMigrateUpgradeFromFileTest.php - Tests migrations with Migrate Upgrade, Drush and Migrate Tools.
File
- tests/
src/ Functional/ DrushWithMigrateUpgradeFromFileTest.php, line 717
Class
- DrushWithMigrateUpgradeFromFileTest
- Tests Migrate Upgrade compatibility and verifies usage steps of README.
Namespace
Drupal\Tests\media_migration\FunctionalCode
public function assertDocumentMediaMigrations(array $media_migrations) {
$document_mimes = $this->sourceDatabase instanceof PostgreSqlConnection ? 'application::text' : 'text::application';
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_type_document',
'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' => $document_mimes,
'schemes' => 'public',
'destination_media_type_id' => 'document',
],
'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_document']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_source_field_document',
'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' => $document_mimes,
'schemes' => 'public',
'destination_media_type_id' => 'document',
],
'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_document',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_source_field_document']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_source_field_config_document',
'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' => $document_mimes,
'schemes' => 'public',
'destination_media_type_id' => 'document',
],
'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_document',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_source_field_config_document']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_formatter_document',
'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' => $document_mimes,
'schemes' => 'public',
'destination_media_type_id' => 'document',
],
'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_document',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_formatter_document']));
// Widget settings migration.
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_widget_document',
'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' => $document_mimes,
'schemes' => 'public',
'destination_media_type_id' => 'document',
],
'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_document',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_widget_document']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_application_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' => 'application',
'scheme' => 'public',
'destination_media_type_id' => 'document',
],
'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_document/target_id' => [
[
'plugin' => 'get',
'source' => 'fid',
],
],
'field_media_document/display' => [
[
'plugin' => 'get',
'source' => 'display',
],
],
'field_media_document/description' => [
[
'plugin' => 'get',
'source' => 'description',
],
],
],
'destination' => [
'plugin' => 'entity:media',
],
'migration_dependencies' => [
'required' => [
'upgrade_d7_file_plain_type_document',
'upgrade_d7_file_plain_source_field_config_document',
'upgrade_d7_file',
],
'optional' => [
'upgrade_d7_user',
],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_application_public']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_plain_text_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' => 'text',
'scheme' => 'public',
'destination_media_type_id' => 'document',
],
'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_document/target_id' => [
[
'plugin' => 'get',
'source' => 'fid',
],
],
'field_media_document/display' => [
[
'plugin' => 'get',
'source' => 'display',
],
],
'field_media_document/description' => [
[
'plugin' => 'get',
'source' => 'description',
],
],
],
'destination' => [
'plugin' => 'entity:media',
],
'migration_dependencies' => [
'required' => [
'upgrade_d7_file_plain_type_document',
'upgrade_d7_file_plain_source_field_config_document',
'upgrade_d7_file',
],
'optional' => [
'upgrade_d7_user',
],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_plain_text_public']));
}