public function MediaMigrationTest::testMediaMigration in Media Migration 8
Tests the migration of media entities.
@dataProvider providerTestMediaMigration
1 call to MediaMigrationTest::testMediaMigration()
- MediaMigrationTest::testChangeTracking in tests/
src/ Kernel/ Migrate/ MediaMigrationTest.php - Tests media entity migration with change tracking enabled.
File
- tests/
src/ Kernel/ Migrate/ MediaMigrationTest.php, line 57
Class
- MediaMigrationTest
- Tests media migration.
Namespace
Drupal\Tests\media_migration\Kernel\MigrateCode
public function testMediaMigration(string $destination_token, string $reference_method, bool $classic_node_migration, array $expected_node1_embed_attributes, bool $preexisting_media_types) {
if ($preexisting_media_types) {
$this
->createStandardMediaTypes();
}
$this
->setEmbedTokenDestinationFilterPlugin($destination_token);
$this
->setEmbedMediaReferenceMethod($reference_method);
$this
->setClassicNodeMigration($classic_node_migration);
$this
->assertArticleBodyFieldMigrationProcesses($classic_node_migration ? 'd7_node:article' : 'd7_node_complete:article', [
[
'plugin' => 'get',
'source' => 'body',
],
[
'plugin' => 'media_wysiwyg_filter',
],
[
'plugin' => 'img_tag_to_embed',
],
]);
// Assert that field migration dependencies were added.
$manager = $this->container
->get('plugin.manager.migration');
assert($manager instanceof MigrationPluginManagerInterface);
$node_migration = $manager
->createInstance($classic_node_migration ? 'd7_node:article' : 'd7_node_complete:article');
assert($node_migration instanceof Migration);
// We have to re-index the dependencies.
$dependencies = array_map(function (array $dependencies) {
natsort($dependencies);
return array_values(array_unique($dependencies));
}, $node_migration
->getMigrationDependencies());
$this
->assertEquals([
'required' => [
'd7_file_entity:image:public',
'd7_file_entity:video:public',
'd7_file_entity:video:vimeo',
'd7_file_entity:video:youtube',
'd7_node_type',
'd7_user',
],
'optional' => [
'd7_comment_field_instance',
'd7_field_instance',
],
], $dependencies);
// Execute the media migrations.
$this
->executeMediaMigrations($classic_node_migration);
// Check configurations.
$this
->assertArticleImageFieldsAllowedTypes();
$this
->assertArticleMediaFieldsAllowedTypes();
// Check the migrated media entities.
$this
->assertMedia1FieldValues();
$this
->assertMedia2FieldValues();
$this
->assertMedia3FieldValues();
$this
->assertMedia4FieldValues();
$this
->assertMedia5FieldValues();
$this
->assertMedia6FieldValues();
$this
->assertMedia7FieldValues();
$this
->assertMedia8FieldValues();
$this
->assertMedia9FieldValues();
$this
->assertMedia10FieldValues();
$this
->assertMedia11FieldValues();
$this
->assertMedia12FieldValues();
$this
->assertNode1FieldValues($expected_node1_embed_attributes);
$this
->assertFilterFormats();
}