public function DrushWithMigrateUpgradeFromMediaTest::assertRemoteVideoMediaMigrations in Media Migration 8
Tests remote video (Vimeo and YouTube) media migrations.
Parameters
\Drupal\migrate_plus\Entity\MigrationInterface[] $media_migrations: Array of migration entities tagged with MediaMigration::MIGRATION_TAG.
1 call to DrushWithMigrateUpgradeFromMediaTest::assertRemoteVideoMediaMigrations()
- DrushWithMigrateUpgradeFromMediaTest::testMigrationWithDrush in tests/
src/ Functional/ DrushWithMigrateUpgradeFromMediaTest.php - Tests migrations with Migrate Upgrade, Drush and Migrate Tools.
File
- tests/
src/ Functional/ DrushWithMigrateUpgradeFromMediaTest.php, line 1711
Class
- DrushWithMigrateUpgradeFromMediaTest
- Tests Migrate Upgrade compatibility and verifies usage steps of README.
Namespace
Drupal\Tests\media_migration\FunctionalCode
public function assertRemoteVideoMediaMigrations(array $media_migrations) {
// PostgreSQL returns differently sorted results.
$remote_video_schemes = $this->sourceDatabase instanceof PostgreSqlConnection ? 'vimeo::youtube' : 'youtube::vimeo';
$this
->assertEquals([
'id' => 'upgrade_d7_file_entity_type_remote_video',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_entity_type',
'constants' => [
'status' => TRUE,
],
'schemes' => $remote_video_schemes,
'types' => 'video',
'destination_media_type_id' => 'remote_video',
],
'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_entity_type_remote_video']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_entity_source_field_remote_video',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_entity_source_field_storage',
'constants' => [
'entity_type_id' => 'media',
'status' => TRUE,
'langcode' => 'und',
'cardinality' => 1,
],
'schemes' => $remote_video_schemes,
'types' => 'video',
'destination_media_type_id' => 'remote_video',
],
'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_entity_type_remote_video',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_entity_source_field_remote_video']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_entity_source_field_config_remote_video',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_entity_source_field_instance',
'constants' => [
'entity_type_id' => 'media',
'required' => TRUE,
],
'schemes' => $remote_video_schemes,
'types' => 'video',
'destination_media_type_id' => 'remote_video',
],
'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_entity_source_field_remote_video',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_entity_source_field_config_remote_video']));
$this
->assertEquals([
'id' => 'upgrade_d7_file_entity_formatter_remote_video',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_entity_field_formatter',
'constants' => [
'entity_type_id' => 'media',
'view_mode' => 'default',
],
'schemes' => $remote_video_schemes,
'types' => 'video',
'destination_media_type_id' => 'remote_video',
],
'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_entity_source_field_config_remote_video',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_entity_formatter_remote_video']));
// Widget settings migration.
$this
->assertEquals([
'id' => 'upgrade_d7_file_entity_widget_remote_video',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Configuration',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONFIG,
],
'source' => [
'plugin' => 'd7_file_entity_field_widget',
'constants' => [
'entity_type_id' => 'media',
'form_mode' => 'default',
],
'schemes' => $remote_video_schemes,
'types' => 'video',
'destination_media_type_id' => 'remote_video',
],
'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_entity_source_field_config_remote_video',
],
'optional' => [],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_entity_widget_remote_video']));
// Vimeo migration.
$this
->assertEquals([
'id' => 'upgrade_d7_file_entity_video_vimeo',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Content',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONTENT,
],
'source' => [
'plugin' => 'd7_file_entity_item',
'type' => 'video',
'scheme' => 'vimeo',
'destination_media_type_id' => 'remote_video',
],
'process' => [
'uuid' => [
[
'plugin' => 'media_migrate_uuid',
'source' => 'fid',
],
],
'mid' => [
[
'plugin' => 'get',
'source' => 'fid',
],
],
'uid' => [
[
'plugin' => 'migration_lookup',
'migration' => 'upgrade_d7_user',
'source' => 'uid',
],
[
'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_oembed_video/value' => [
[
'plugin' => 'media_internet_field_value',
'source' => 'uri',
],
],
],
'destination' => [
'plugin' => 'entity:media',
],
'migration_dependencies' => [
'required' => [
'upgrade_d7_file_entity_type_remote_video',
'upgrade_d7_file_entity_source_field_config_remote_video',
],
'optional' => [
'upgrade_d7_user',
],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_entity_video_vimeo']));
// Youtube migration.
$this
->assertEquals([
'id' => 'upgrade_d7_file_entity_video_youtube',
'migration_group' => 'migrate_drupal_7',
'migration_tags' => [
'Drupal 7',
'Content',
MediaMigration::MIGRATION_TAG_MAIN,
MediaMigration::MIGRATION_TAG_CONTENT,
],
'source' => [
'plugin' => 'd7_file_entity_item',
'type' => 'video',
'scheme' => 'youtube',
'destination_media_type_id' => 'remote_video',
],
'process' => [
'uuid' => [
[
'plugin' => 'media_migrate_uuid',
'source' => 'fid',
],
],
'mid' => [
[
'plugin' => 'get',
'source' => 'fid',
],
],
'uid' => [
[
'plugin' => 'migration_lookup',
'migration' => 'upgrade_d7_user',
'source' => 'uid',
],
[
'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_oembed_video/value' => [
[
'plugin' => 'media_internet_field_value',
'source' => 'uri',
],
],
],
'destination' => [
'plugin' => 'entity:media',
],
'migration_dependencies' => [
'required' => [
'upgrade_d7_file_entity_type_remote_video',
'upgrade_d7_file_entity_source_field_config_remote_video',
],
'optional' => [
'upgrade_d7_user',
],
],
'dependencies' => [],
], $this
->getImportantEntityProperties($media_migrations['upgrade_d7_file_entity_video_youtube']));
}